microsoft / XamlBehaviors

This is the official home for UWP XAML Behaviors on GitHub.
MIT License
697 stars 112 forks source link

DataTriggerBehavior does not work with all numeric types #140

Open MatrixRonny opened 5 years ago

MatrixRonny commented 5 years ago

I think that DataTriggerBehavior only works with int and double for numeric data. I tested with short, long, float, decimal and it does not work as expected. I used the following code:

public class SampleViewModel
{
  decimal Number { get; set; }
}
public SampleView()
{
  this.InitializeComponent();
  Loaded += SampleView_Loaded;
}

private void SampleView_Loaded(object sender, RoutedEventArgs e)
{
  DataContext = new SampleViewModel { Number = 0 };
}
<TextBlock Text="The test" HorizontalAlignment="Center" VerticalAlignment="Center">
  <Interactivity:Interaction.Behaviors>
    <Core:DataTriggerBehavior Binding="{Binding Number}" ComparisonCondition="GreaterThan" Value="-1">
      <Core:ChangePropertyAction PropertyName="Visibility" Value="Collapsed"/>
    </Core:DataTriggerBehavior> 
  </Interactivity:Interaction.Behaviors>
</TextBlock>
skendrot commented 5 years ago

Thanks for reporting. I can confirm the issue and I'm looking into a fix