【发布时间】:2015-10-12 16:39:19
【问题描述】:
我在 displaymemberpath 中有一个带有连接字符串的组合框(下面代码隐藏中的“DescriptionComplete”),这就是我在可编辑字段中得到的,但这只是我想要进入可编辑字段的 IdEchantillon... 请问我该怎么做?
XAML:
<ComboBox x:Name="cbEchantillon" SelectedValue="{Binding CurrentEchantillon.IdEchantillon}" ItemsSource="{Binding OcEchantillon}" DisplayMemberPath="DescriptionComplete" SelectedValuePath="IdEchantillon" SelectedItem="{Binding CurrentEchantillon}" Text="{Binding IdEchantillon}" IsEditable="True" Width="355" FontSize="14" FontFamily="Courier New" SelectionChanged="cbEchantillon_SelectionChanged"></ComboBox>
后面的代码:
public class Echantillon : ViewModelBase
{
private string _IdEchantillon;
private string _Description;
private DateTime _dateechan;
private string _descriptionComplete;
}
public string IdEchantillon
{
get { return _IdEchantillon; }
set { _IdEchantillon = value; RaisePropertyChanged("IdEchantillon"); }
}
public string Description
{
get { return _Description; }
set { _Description = value; RaisePropertyChanged("Description"); }
}
public DateTime Dateechan
{
get { return _dateechan; }
set { _dateechan = value; RaisePropertyChanged("Dateechan"); }
}
public string DescriptionComplete
{
get { return string.Format("{0} {1} {2}", IdEchantillon.PadRight(20), Dateechan.ToShortDateString(), Description); }
set { _descriptionComplete = value; }
}
}
【问题讨论】:
-
不清楚你在问什么。试着一步一步解释,如果你英语不是很好,就一步一步来。不要试图缩短你的话,很难理解你在这里真正想要什么。
标签: c# wpf xaml combobox selectedvalue