[英]getting null from property binded for selected wpf combobox value
I have class DimensionType, it has properties Name, Id, etc. I constructed Property in my ViewModel = "dimStyleId" to retrieve selected form ComboBox.我有 class DimensionType,它具有名称、ID 等属性。我在 ViewModel = "dimStyleId" 中构造了属性以检索选定的表格 ComboBox。 I am getting null in this property although I checked it in TextBlock and get it.
我在这个属性中得到 null 尽管我在 TextBlock 中检查并得到它。
<!--Dimension Type Combobox-->
<ComboBox x:Name="DimensionType"
ItemsSource="{Binding dimTypes , Mode=TwoWay}"
SelectedValue="{Binding dimStyleId , Mode=TwoWay}"
SelectedValuePath="DimensionType"
DisplayMemberPath="Name"
Padding="3" />
and here is my VM Class这是我的虚拟机 Class
public class GridsDimViewModel : INotifyPropertyChanged
{
public ElementId dimensionType;
private ElementId _dimStyleId { get; set; }
public ElementId dimStyleId
{
get
{
return _dimStyleId;
}
set
{
if (_dimStyleId != value)
{
_dimStyleId = value;
NotifyPropertyChanged(nameof(dimStyleId));
}
}
}
}
and here is my check textbox which gets the id in it这是我的检查文本框,其中包含 id
<TextBlock Text="{Binding dimStyleId}"
Padding="3" />
Swap交换
SelectedValuePath="DimensionType"
to至
SelectedValuePath="Id"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.