Wpf 将静态类绑定到ListBox和TextBlock

Wpf 将静态类绑定到ListBox和TextBlock,wpf,binding,static,Wpf,Binding,Static,--编辑-- 如何绑定到以下内容: -MyProfile.Friends To List框,其中包含有好友姓名的文本块 -MyProfile.Profile.Name To Textblock确保在xaml中为C#名称空间定义名称空间。我把它命名为本地的 <ListBox ItemsSource="{Binding Source={x:Static local:MyProfile.Friends}"> <ListBox.ItemTemplate> <Da

--编辑--

如何绑定到以下内容:
-MyProfile.Friends To List框,其中包含有好友姓名的文本块

-MyProfile.Profile.Name To Textblock

确保在xaml中为C#名称空间定义名称空间。我把它命名为本地的

<ListBox ItemsSource="{Binding Source={x:Static local:MyProfile.Friends}">
  <ListBox.ItemTemplate>
    <DataTemplate>
      <TextBlock Text="{Binding Profile.Name}" />
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>
MyProfile.Friends To List框,其中包含有好友姓名的文本块

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.Profile.Name到Textblock

<ListBox ItemsSource="{Binding Source={x:Static local:MyProfile.Friends}">
  <ListBox.ItemTemplate>
    <DataTemplate>
      <TextBlock Text="{Binding Profile.Name}" />
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>


不工作,因为我没有任何价值;所以我用Myprofile做了一个listview绑定。朋友们,如何将名称绑定到listview中的文本块在你编辑这个问题之前,你确实有人给过你值。不不,不,你不理解我,我写了任何人,因为我不知道。请确保类实现INotifyPropertyChanged接口。这对于Profile类应该足够了。对于朋友,我认为您应该使用ObservableCollection类:。我成功地将它用于类似的工作。我也不确定这些字段是否是静态的。他们会让你用static关键字实现接口吗?