wpfui
wpfui copied to clipboard
Wpf.Ui.Controls.NumberBox event ValueChanged called early
Describe the bug
ValueChanged event is called before the binded value changes
To Reproduce
with this piece of code we can see that NumberBox.Value is the correct value but the binded value doesn't.
<StackPanel Grid.Row="2" Margin="20" Grid.ColumnSpan="2">
<ui:NumberBox Value="{Binding testValue}" ValueChanged="NumberBox_ValueChanged" HorizontalAlignment="Left"/>
<TextBlock x:Name="bugReport" TextWrapping="Wrap"/>
</StackPanel>
public double testValue { get; set; } = 10.12345567788;
private void NumberBox_ValueChanged(object sender, System.Windows.RoutedEventArgs e) {
if(bugReport == null)
return;
bugReport.Text += $" - {( (NumberBox)sender ).Value.ToString()} ({testValue})";
}
Expected behavior
The event is called after the binded value is associated
Screenshots
OS version
Window 11
.NET version
.net 9.0
WPF-UI NuGet version
3.0.5
Additional context
No response
I'm experiencing the same issue. However, when I adjust the value using the up and down arrows, it works fine.
I also noticed that the border of the NumberBox turns red when I try to set the value for the second time, I'm not entirely sure why this happens, but as @APerricone mentioned, it might be due to a delay in the binding.