我有以下问题:WPF如何绑定tabitem与列表
我有一些数据加载在我的应用程序,需要放在一个选项卡控件。
的数据的格式为:
class objectType1
{
string property_1;
string prorerty_2;
}
class mainObject
{
string mainProperty_1;
string mainProperty_2;
List<objectType1> objectsList;
}
并且所有数据在类型的对象加载
List<mainObject> myListofObjects
到目前为止我设法创建相对于所述的TabItems到myListofObjects项 (即如果列表有5个对象,5个标签包含信息mainProperty_1和mainProperty_2的标题创建) 现在我需要将每个objectsList中包含的数据添加到其各自的标签...
的mainProperty_1代表的图像,必须加载中...
<TabControl x:Name="_DataList" Margin="10">
<!-- Header -->
<TabControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Height="18" Source="{Binding mainProperty_1/>
<TextBlock Text="{Binding mainProperty_2}" Margin="2,0,0,0" />
</StackPanel>
</DataTemplate>
</TabControl.ItemTemplate>
<!-- Content -->
<TabControl.ContentTemplate>
<DataTemplate x:Name="objectDataTemplate">
<Grid Margin="5">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding property_1}" ToolTip="{Binding property_2}" IsHitTestVisible="false" Stretch="Uniform"/>
</StackPanel>
</Grid>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
我将数据传递到TabControl在后面的代码与
_DataList.ItemsSource = myListofObjects;
这是不工作的内容。 ..
标题加载就好(图片和文字...)
任何人有什么想法如何做到这一点?
非常感谢!
感谢您的回答!不幸的是,行 引发错误“类型引用无法找到名为'objectType1'的公共类型' ,尽管类定义是公共的,以及mainObject类中的List定义类... 再次感谢! –
geo
2011-03-22 14:35:43
好的。我明白了! 非常感谢! – geo 2011-03-22 14:58:53