Ter*_*lis 1 c# wpf xaml binding datatemplate
我有一个类,为了实验起见,调用它foo()和另一个类,调用它bar()
我有一个数据模板,用于在我的xaml中定义的类foo(),但是foo()的一个属性是一个bar( )这样的对象
foo()
{
Public string Name {get; set;}
Public int ID {get; set;}
Public bar barProp {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
和
bar()
{
Public string Description{get; set;}
}
Run Code Online (Sandbox Code Playgroud)
我希望我的foo数据模板显示bar的Description属性.我尝试过简单<textblock Text="{Binding Path=barProp.Description}" />和变体无济于事
寻求智慧,
DJ
编辑:根据更多信息的要求...
这是我真正的课程......
public class AccountRecord
{
public string Value { get; set; }
public string Identifier { get; set; }
public Field AccountNumber;
}
public class Field
{
public string Name{get;set;}
public string Value{get;set}
}
Run Code Online (Sandbox Code Playgroud)
这里是用于模板化它们的XAML ......
<ListBox Margin="0,35,0,0" Name="listAccountRecords" Background="Transparent" BorderBrush="Transparent" ItemsSource="{Binding AccountRecords, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type lib:AccountRecord}">
<Expander Header="{Binding AccountNumber.Name}">
<ListView ItemsSource="{Binding Fields}" ItemTemplate="{DynamicResource FieldTemplate}">
</ListView>
</Expander>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
确切的问题是AccountNumber.Name值没有出现在AccountRecord元素的扩展器头中
| 归档时间: |
|
| 查看次数: |
2061 次 |
| 最近记录: |