0
我試圖找出相當長的一段時間。我想Databind列表框中有一個Dataset.Simple,因爲它可以get.But我的問題是我希望我的datatemplate顯示來自兩個表中的列,在數據集中。我嘗試了許多samles ..但我發現的一切只是給數據集作爲datacontext,並提供一個表作爲itemsource.But我的情況是,我想要更多比我的DataTemplate一個表..數據綁定數據集到列表框... Datatemplate需要顯示多列
對於如:
<DataTemplate x:Key="EmployeeDataTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Margin="5" BorderBrush="Black" BorderThickness="1">
<Image Source="{Binding Path=Mast/Image}" Stretch="Fill" Width="50" Height="50" />
</Border>
<StackPanel Grid.Column="1" Margin="5">
<StackPanel Orientation="Horizontal" TextBlock.FontWeight="Bold" >
<TextBlock Text="{Binding Path=Mast/Firstname}" />
<TextBlock Text="{Binding Path=Mast/Lastname}" Padding="3,0,0,0"/>
</StackPanel>
<TextBlock Text="{Binding Path=Details/Age}" />
<TextBlock Text="{Binding Path=Details/Role}" />
</StackPanel>
</Grid>
</DataTemplate>
任何方式做到這一點..?我很困惑...!
我試着給數據集作爲的datacontext和作爲的ItemSource綁定{}但只顯示一行...
感謝阿維亞德......我試圖做同樣的,但我有一些疑問首先,我不能在一個正常的數據集上做這個權利..?我想我必須使用一個strogly類型的datset..for例如一個XSD實例。我試圖用xsd實現這一點,但我無法通過,我得到了一些錯誤..在 返回masterRow.GetDetailsTableRows(); 我得到錯誤becasue GetDetailsTableRows()無法找到。我正在做的事情.. ..?我可以有一個工作樣本..?在此先感謝... – biju 2010-01-08 13:45:12
是的我的示例使用強類型的數據集與一個'MasterTable'和一個'DetailsTable'你可以修改上面的示例使用常規(非類型)數據集,通過使用'GetChildRows'並傳遞關係。 – 2010-01-08 14:52:18