I have a XamNumeric editor and a Slider to ease the percentage input.
The problem is that as soon as the user changes the value with the slider, the spin buttons in the editor get disabled .
I have the following xaml:
<InfragisticsWpf:XamNumericEditor x:Name="PercentEditor"
Value="{Binding Percent, Mode=TwoWay}"
ValueType="{x:Type System:Decimal}"
Mask="nnn %"
SpinButtonDisplayMode="Always">
<InfragisticsWpf:XamNumericEditor.ValueConstraint>
<InfragisticsWpf:ValueConstraint MinInclusive="0" MaxInclusive="100"/>
</InfragisticsWpf:XamNumericEditor.ValueConstraint>
</InfragisticsWpf:XamNumericEditor>
<Slider
Value="{Binding ElementName=PercentEditor, Path=Value, Mode=TwoWay, Converter={StaticResource DoubleToDecimalConverter}}"
Minimum="0"
Maximum="100"
IsSnapToTickEnabled="True"
VerticalContentAlignment="Center"
VerticalAlignment="Center"
TickFrequency="5">
</Slider>
Any ideas?
Ater some more debugging I have found a solution. The problem with the XamNumericEditor is that on the binding from the other controls it sets the carret poistion on the end of the visible value (% in my case) that's why the spin buttons do not work. To correct the problem I added the following handler:
void NumericEditorOnGotFocus(object sender, RoutedEventArgs e) { var numericEditor = sender as XamNumericEditor; if (numericEditor != null) { var text = numericEditor.Text; var numberMatch = Regex.Match(text, @"\\d"); if (numberMatch.Success) { numericEditor.SelectionStart = numberMatch.Index; } } }
I know this is not the best idea as I had add the handler in the code behind. I would prefer to have a solution directly in the Xaml file, but this solves the issue.
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.