私は車を持っていますIEnumerable
:
public IEnumerable<ICars> Cars { get; private set; }
オブジェクト「Car」には、実際にはタイプ IBrand の別のオブジェクトへの参照が含まれています。
public interface ICar
{
// Parent brand accessor
IBrand Brand { get; set; }
// Properties
int CarId { get; set; }
string CarName { get; set; }
}
IBrand インターフェイスにはいくつかのプロパティがあります。
public interface IBrand
{
// Properties
string LogoName { get; set; }
string Sector { get; set; }
}
私はこの Cars IEnumerable を DataGrid にバインドしています -これは完全にうまくいきます:
<DataGrid Name="Cars"
ItemsSource="{Binding}"
SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}, AncestorLevel=2}, Path=SelectedCar, Mode=TwoWay}">
<DataGrid.Columns>
<DataGridTextColumn Header="Car Id"
Binding="{Binding CarId}"
IsReadOnly="True" />
<DataGridTextColumn Header="Car Name"
Binding="{Binding CarName}"
IsReadOnly="True" />
</DataGrid.Columns>
私の問題は、ロゴなど、ブランドのいくつかのプロパティもバインドしたいということです(すべての車に共通)。ただし、このシンタックスは機能しません。
<DataGridTextColumn Header="Logo Name"
Binding="{Binding Brand.LogoName}"
IsReadOnly="True" />
その方法について何か考えはありますか?ありがとうございました!