Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WINUI]Binding not works properly in NumberBox when binded a Nullable float property #8830

Open
sethuramkumar opened this issue Sep 5, 2023 · 0 comments
Labels
area-XamlCompiler bug Something isn't working team-Markup Issue for the Markup team

Comments

@sethuramkumar
Copy link

Describe the bug

Binding not works properly in NumberBox when binded a Nullable float property

**MainWindow.xaml**
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="Binded with Double Nullable Property" FontWeight="Medium"/>
    <NumberBox Width="200" Height="30" Value="{Binding Price,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
    <NumberBox Width="200" Height="30" Value="{Binding Price,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
    <TextBlock Text="Binded with Float Nullable Property" FontWeight="Medium"/>
    <NumberBox Width="200" Height="30" Value="{Binding Rate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
    <NumberBox Width="200" Height="30" Value="{Binding Rate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
    <StackPanel.DataContext>
        <local:ViewModel/>
    </StackPanel.DataContext>
</StackPanel>

**ViewModel**
 public class ViewModel : INotifyPropertyChanged
 {
     private double? _price;
     public double? Price { get { return _price; } set { _price = value; RaisePropertyChanged("Price"); } }

     private float? _rate;
     public float? Rate { get { return _rate; } set { _rate = value; RaisePropertyChanged("Rate"); } }
     public ViewModel() { }

     public event PropertyChangedEventHandler PropertyChanged;

     public void RaisePropertyChanged(string propertyName) 
     {
         PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
     }
 }

Steps to reproduce the bug

1.Declare a Numberbox and bind a value property of NumberBox to a Nullable float property.
2.Declare another Numberbox and bind a value property of NumberBox to the same Nullable float property.
3.Edit the value in the first Number Box.

Observed Behavior:
Value is not updated based on binding.
Note: For Nullable double property it works properly.

Expected behavior

Edited value should be reflected in both the number box because of binding.

Screenshots

NumberBoxDemo.mp4

NuGet package version

WinUI 3 - Windows App SDK 1.4.0: 1.4.230822000

Windows version

Windows 11 (21H2): Build 22000

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-XamlCompiler bug Something isn't working team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

2 participants