C# 如何从App.xaml设置绑定到childproperty
绑定到ListBox控件时出现问题。 实际上,我在App.xaml.cs中有一个属性:C# 如何从App.xaml设置绑定到childproperty,c#,wpf,binding,telerik,inotifypropertychanged,C#,Wpf,Binding,Telerik,Inotifypropertychanged,绑定到ListBox控件时出现问题。 实际上,我在App.xaml.cs中有一个属性: public partial class App : Application, INotifyPropertyChanged { ObservableCollection<Panier> _panier = new ObservableCollection<Panier>(); public ObservableCollection<Panier> Pan
public partial class App : Application, INotifyPropertyChanged
{
ObservableCollection<Panier> _panier = new ObservableCollection<Panier>();
public ObservableCollection<Panier> PanierProperty
{
get { return _panier; }
set
{
if (this._panier != value)
{
this._panier = value;
NotifyPropertyChanged("PanierProperty");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(String property)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
}
在我的MainWindow.xaml页面中,我将我的列表框绑定到PanierProperty(父属性):
我的问题是PanierProperty绑定到我的Listbox,我在Listbox中看到类似Design.Panier的项
设计.窗格玻璃
设计.窗格玻璃
等
我不知道如何获取PanierProperty.Nom(Nom是子属性)以显示在列表框中
有人可以帮忙。在
DisplayMemberPath
中,使用您只想显示的属性名称:
<telerik:RadListBox
...
DisplayMemberPath="Nom"
非常感谢它让我发疯:s我只是在尝试使用{Binding Nom}不知道,谢谢:D
<telerik:RadListBox x:Name="PanierLB" Grid.Row="1" Height="200" Width="350" Margin="0 300 0 0"
ItemsSource="{Binding PanierProperty, Source={x:Static Application.Current}}"
DisplayMemberPath="{Binding Path=PanierProperty.Nom, Source={x:Static Application.Current}}">
</telerik:RadListBox>
<telerik:RadListBox
...
DisplayMemberPath="Nom"