对WPF缺乏经验,所以我需要一点帮助。提前感谢你的帮助。
我有以下课程:
public class TabDefn
{
public TabDefn() { }
public TabDefn(string inFolderName, List<FilesFolder> inFilesFolders)
{
folderName = inFolderName;
FFs = inFilesFolders;
}
public string folderName { get; set; }
public List<FilesFolder> FFs {get; set;}
}
public class FilesFolder
{
public FilesFolder() {}
//public Image image { get; set; }
public string ffName { get; set; }
//public Image arrow { get; set; }
}TabControl.ItemContent运行良好。我不能为TabControl.ContentTemplate找到任何东西。我尝试过很多东西,但现在WPF就在这里:
<TabControl Grid.Column="1" Grid.Row="1" Visibility="Hidden" Name="Actions">
<!-- This displays the tab heading perfectly.-->
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding folderName}" />
</DataTemplate>
</TabControl.ItemTemplate>
<!-- This is the content of the tab that I can't get anything to show up in.-->
<TabControl.ContentTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding FF}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBox Text="{Binding ffName}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>我不在乎内容是否改变,所以我不需要INotifyPropertyChanged或ObservableCollection。但是,如果我必须把所有的代码都放进去,那就去吧。
发布于 2014-05-12 12:30:04
您将FF声明为无效绑定源的字段。您需要将其转换为属性。
public List<FilesFolders> FF { get; set; }并初始化它,例如在TabDefn构造函数中。您可以找到更多关于什么是MSDN上的有效绑定源的信息。
https://stackoverflow.com/questions/23608767
复制相似问题