0
DoubleUpDown
コントロールにテキストを入力すると、コントロールがリセットされ、コントロールが赤で強調表示されます。 それは次のようになります。DoubleUpDown検証のスタイルをデフォルトのようにするにはどうすればよいですか?
にはどうすれば負の数に同じスタイルを適用することができますか?
私はPositiveNumberToColorConverter
を作成することによって、それを行うと、それは国境を魔女適用:
public class PositiveNumberToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(value is int?)
{
var intValue = (int?)value;
if (intValue == null)
return Brushes.Transparent;
else if (intValue.HasValue&&intValue.Value>=0)
return Brushes.Transparent;
else if(intValue.HasValue==false)
return Brushes.Transparent;
return Brushes.Red;
}
return Brushes.Red;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
<Border
Grid.Column="0"
BorderThickness="1"
Background="Transparent"
BorderBrush="{Binding ObjectViewModel.Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource positiveNumberConverter}}"
IsEnabled="{Binding ObjectViewModel.IsEnabled,Mode=TwoWay,TargetNullValue=False,FallbackValue=False,UpdateSourceTrigger=PropertyChanged}"
>
<xcd:DoubleUpDown
HorizontalAlignment="Stretch"
Margin="5"
Grid.Column="0"
Minimum="0"
Height="{Binding ElementName=tbName,Path=Height}"
Width="Auto"
IsEnabled="{Binding ObjectViewModel.IsEnabled,Mode=TwoWay,TargetNullValue=False,FallbackValue=False,UpdateSourceTrigger=PropertyChanged}"
Text="{Binding ObjectViewModel.Value,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" >
<xcd:DoubleUpDown.Resources>
<Style TargetType="Popup">
<Setter Property="TextBlock.TextAlignment" Value="Left"/>
</Style>
</xcd:DoubleUpDown.Resources>
</xcd:DoubleUpDown>
</Border>
しかし、それは次のようになります。負の数の入力になるようにする方法
それは最初の画像のように強調表示されています(テキスト入力のためにデフォルトでどのように制御されていますか)。
まだありません。私は今それを試してみる –