绑定到友元属性的WPF
我正在从事两个项目:绑定到友元属性的WPF,wpf,data-binding,binding,Wpf,Data Binding,Binding,我正在从事两个项目: 一个业务逻辑层,它是一个类库,包含我的所有对象和应用程序的业务规则(我将把它称为我的BLL) 使用BLL的WPF应用程序 BLL中的Person类(目前唯一的类)的作用域修饰符设置为Friend(与Public一致),我已允许WPF应用程序使用Runtime.CompilerServices.InternalsVisibleTo属性访问该类 WPF应用程序引用BLL并具有以下组件 其中的PersonViewModel类包装了BLL的Person类 MainWindow.xa
如何向XAML公开Friend属性,以便它显示该属性
谢谢你抽出时间
-Frinny我明白了
我将PersonViewModel类设置为好友而不是Public,并将Person属性更改为Public。这允许XAML显示好友信息
像这样:
Imports BuisnessLogicLayer
Friend Class PersonViewModel
Private _person As Person
'Friend Property Person As Person'
Public Property Person As Person
Get
Return _person
End Get
Set(ByVal value As Person)
_person = value
End Set
End Property
Public Sub New()
_person = New Person
End Sub
End Class
再次感谢您抽出时间
-Frinny我明白了
我将PersonViewModel类设置为好友而不是Public,并将Person属性更改为Public。这允许XAML显示好友信息
像这样:
Imports BuisnessLogicLayer
Friend Class PersonViewModel
Private _person As Person
'Friend Property Person As Person'
Public Property Person As Person
Get
Return _person
End Get
Set(ByVal value As Person)
_person = value
End Set
End Property
Public Sub New()
_person = New Person
End Sub
End Class
再次感谢您抽出时间
-弗里尼
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wpfFriendTest="clr-namespace:WPFFriendTest"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<StackPanel.Resources>
<wpfFriendTest:PersonViewModel x:Key="personVM"></wpfFriendTest:PersonViewModel>
</StackPanel.Resources>
<StackPanel Orientation="Horizontal" DataContext="{StaticResource personVM}">
<Label Content="Name: "></Label>
<TextBox Text="{Binding Person.Name}" Width="200"></TextBox>
</StackPanel>
</StackPanel>
</Window>
Imports BuisnessLogicLayer
Friend Class PersonViewModel
Private _person As Person
'Friend Property Person As Person'
Public Property Person As Person
Get
Return _person
End Get
Set(ByVal value As Person)
_person = value
End Set
End Property
Public Sub New()
_person = New Person
End Sub
End Class