Search code examples
c#wpfxamlmvvmxceed

Disable Text Input For IntegerUpDown Control - WPF


I have an IntegerUpDown control which is from the WPF Extended Library (Xceed). I want the user only to use the up / down arrorw to enter a value and not to be able to type a value in

I have tried using the IsReadOnly property but this also disables the up / down arrors as well.

<xctk:IntegerUpDown  IsReadOnly="True" DisplayDefaultValueOnEmptyText="True" GotFocus="Day_GotFocus" LostFocus="Day_LostFocus" x:Name="Day" Value="{Binding DayText, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Style="{StaticResource BaseDateInputTextBoxesStyle}" Minimum="{Binding MinimumDateSelection}" Maximum="{Binding MaximumDateSelection}">
    <xctk:IntegerUpDown.Watermark>
        <TextBlock Text="Day" Foreground="{StaticResource OffsetWhiteBrush}" Margin="0,0,60,0"/>
    </xctk:IntegerUpDown.Watermark>
</xctk:IntegerUpDown>

How can I disable the textbox area so the user cannot type a value and only use the up / down arrow keys?


Solution

  • IntegerUpDown has a property to meet your request : AllowTextInput="False"