1
null을 전송할 방법이 있습니까? 그렇게하려고하면 0으로 간주됩니다. Business-Class 및 SQL-Table에서는 속성이 nullable입니다. Im는 ClearSelectionButton과 함께 ComboBox를 사용하므로 이미 뷰에서이를 수정하는 방법이있을 수 있습니다. 보기에null이 아닌 0 - int로 설정
내 콤보
<telerik:RadComboBox x:Name="CommandButton" ItemsSource="{Binding Path=ColorList}"
SelectedValue="{Binding Path=Model.Color, Converter={StaticResource VCShortIntToInt}, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}"
DisplayMemberPath="Text" SelectedValuePath="number" ClearSelectionButtonVisibility="Visible" ClearSelectionButtonContent="empty" />
비즈니스 클래스
public static PropertyInfo<short?> ColorProperty = RegisterProperty<short?>(c=>c.Color);
public short? Color
{
get { return GetProperty<short?>(ColorProperty); }
set { SetProperty<short?>(ColorProperty, value); }
}
변환기
public class VCShortIntToInt : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Int32 result = 0;
if (value != null && value.GetType() == typeof(Int16))
{
result = System.Convert.ToInt32(value);
}
return result;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
Int16 result = 0;
if (value != null && value.GetType() == typeof(Int32))
{
result = System.Convert.ToInt16(value);
}
return result;
}
}