在XAML中更改Minimum RangeBase时,滑块控件会触发ValueChanged事件 [英] Slider control fires ValueChanged event when changing Minimum RangeBase in xaml

查看:90
本文介绍了在XAML中更改Minimum RangeBase时,滑块控件会触发ValueChanged事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Should the slider control fire the ValueChanged event just by changing the Minimum rangebase? The default minimum is 0. If you set that to some other value (i.e. 2) in the xaml, then this event is fired immediately from the page's constructor, before the page even calls OnNavigatedTo. So if you try to update your DataContext from the ValueChanged event your app will crash since the DataContext hasn't been set yet.

推荐答案

解决此问题的最干净的方法可能是推迟订阅ValueChanged事件,直到设置了最小基本范围为止.

Maybe the cleanest way to address this is to hold off subscribing to the ValueChanged event until after the Minimum baserange is set.

或者在尝试使用DataContext之前对其进行测试.

Or test DataContext before trying to use it.

-马克


这篇关于在XAML中更改Minimum RangeBase时,滑块控件会触发ValueChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆