0
我在兩個項目上工作:WPF綁定到朋友物業
- 業務邏輯層這是包含所有我的目標和我的應用程序的業務規則的類庫(我要指這是我的BLL),採用BLL內BLL
Person類(目前唯一的類)有一個作用域修飾符設置爲朋友(如並列爲public),我有
的WPF應用程序引用BLL和具有以下組件
-
內它
- 甲PersonViewModel類,它包裝BLL的Person類
- 甲MainWindow.xaml(和它的對應的MainWindow.xaml.vb文件)
由於Person類是朋友,我不得不在PersonViewModel中將Person類暴露給MainWindow.xaml Friend。
問題是,當我運行應用程序時,該人員的姓名屬性從不出現。
下面是從BLL我Person類(請注意, 「WPFFriendTest」 是WPF應用程序的組件名稱):
<Assembly: Runtime.CompilerServices.InternalsVisibleTo("WPFFriendTest")>
Friend Class Person
'Public Class Person'
Private _name As String
Public Property Name As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Sub New()
_name = "Frinavale Soldevi"
End Sub
Public Sub New(ByVal name As String)
_name = name
End Sub
End Class
這裏是我PersonViewModel類:
Imports BuisnessLogicLayer
Public Class PersonViewModel
Private _person As Person
'Public Property Person As Person'
Friend 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
而且這裏是我的MainWindow.xaml(這個窗口沒有代碼):
<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>
c我將Friend屬性暴露給XAML,以便它顯示該屬性?
謝謝你的時間!
-Frinny