User Class
- Name
- Picture
Friend Class
- Profile Of Type User
- Age
MyProfile STATIC Class
- STATIC Profile Of Type User
- STATIC Friends Collection Of Type Friend
- 编辑 -
如何绑定到以下内容:
- MyProfile.Friends To List Box包含文本块以拥有朋友姓名
- MyProfile.Profile.Name To Textblock
答案 0 :(得分:2)
确保在xaml中将命名空间定义到C#命名空间。我把它命名为本地。
MyProfile.Friends To List Box包含有朋友姓名的文本块
<ListBox ItemsSource="{Binding Source={x:Static local:MyProfile.Friends}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Profile.Name}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
MyProfile.Profile.Name To Textblock
<TextBlock Text="{Binding Source={x:Static local:MyProfile.Profile.Name}" />