Binding static class to ListBox and TextBlock
User Class
- Name
- Picture
Friend Class
- Profile Of Type User
- Age
MyProfile STATIC Class
- STATIC Profile Of Type User
- STATIC Friends Collection O开发者_运维百科f Type Friend
-- EDIT --
How to bind to the following :
- MyProfile.Friends To List Box which Contains Text blocks to have Friends Names - MyProfile.Profile.Name To TextblockMake sure you define a namespace in your xaml to your C# namespace. I've named it local.
MyProfile.Friends To List Box which Contains Text blocks to have Friends Names
<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}" />
精彩评论