[英]getting null from property binded for selected wpf combobox value
我有 class DimensionType,它具有名稱、ID 等屬性。我在 ViewModel = "dimStyleId" 中構造了屬性以檢索選定的表格 ComboBox。 我在這個屬性中得到 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" />
這是我的虛擬機 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));
}
}
}
}
這是我的檢查文本框,其中包含 id
<TextBlock Text="{Binding dimStyleId}"
Padding="3" />
交換
SelectedValuePath="DimensionType"
至
SelectedValuePath="Id"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.