开发者

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 Textblock


Make 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}" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜