简体   繁体   中英

Item enabled on form load even though it's IsEnabled is bound to a presumably false value

I expect LastNumberWeeks NumericUpDown to be disabled on form load but it isn't. Once I switch the radio selection back and forth it works properly, just not on first load. Outside of explicitly setting this value in the code behind what can I do (I really don't want to have to use a code behind because of this one case).

<RadioButton GroupName="DayRangeGroup" Content="Last number of usable occurences:"  Name="LastUsableOccurancesRadioButton" IsChecked="True" />           
<winControls:NumericUpDown x:Name="LastUsableOccurances" IsEnabled="{Binding ElementName=LastUsableOccurancesRadioButton, Path=IsChecked}"   />      
<RadioButton GroupName="DayRangeGroup"Content="Last number of weeks:"  Name="LastNumberOfWeeksRadioButton"  />          
<winControls:NumericUpDown x:Name="LastNumberWeeks" IsEnabled="{Binding ElementName=LastNumberOfWeeksRadioButton, Path=IsChecked}" />

I just tested the XAML with a TextBox instead of the winControls:NumericUpDown and it is working as expected on load, so it's not a problem with the XAML. Try setting the UpdateSourceTrigger to PropertyChanged to see if it might help. You can also try using a view model to bind to instead of binding to the element.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM