Search code examples
avalonia

How to disable a mouse scroll in Avalonia CalendarDatePicker?


I need to disable the mouse scroll functionality of the CalendarDatePicker. So far, I have not found anywhere how I can do this.

<CalendarDatePicker FontWeight="SemiBold" DisplayDateStart="{Binding
                     Source={x:Static sys:DateTime.Now}, StringFormat=dd/MMM/yyyy}" 
                    SelectedDate="{Binding ExpiredDate}" 
                    IsTodayHighlighted="True" BorderThickness="0" 
                    VerticalContentAlignment="Center" HorizontalAlignment="Center" Background="Transparent"  
                    Watermark="Выберите дату"
                    IsEnabled="{Binding !Status}"
                    Grid.Column="1"></CalendarDatePicker>

How can i do this?

I am not aware of the CalendarDatePicker property to disable mouse scroll functionality


Solution

  • Just about to ask the same question! My first approach was to try handling the PointerWheelChanged event, and simply using e.Handled = true; to prevent the event from being fired. For some reason I couldn't get the event to trigger, but this might work for you.

    I ended up using a button with a Calender in a flyout, which worked nicely.

     <Button Content="{Binding Date, StringFormat='\{0:d\}'}">
        <Button.Flyout>
            <Flyout>
                <Calendar SelectedDate="{Binding Date}"></Calendar>
            </Flyout>
        </Button.Flyout>
    </Button>