-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
Description
The WPF DataTrigger does not trigger if a custom markup extension is used that contains a property named "Value" but the trigger works if any other property name is used.
Reproduction Steps
The bug can be reproduced with the following minimal example:
- Create a new WPF project.
- Create a class that inherits from Binding and contains a property "Value":
public class TestBindingExtension : Binding
{
public TestBindingExtension() : base() { }
public TestBindingExtension(string path) : base(path) { }
public object? Value { get; set; }
}
- Add a TextBlock to the Window with the following style:
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Text" Value="NOT EXPECTED"/>
<Style.Triggers>
<DataTrigger Binding="{local:TestBinding Path=IsExpected, Value=anyvalue}" Value="True">
<Setter Property="Text" Value="EXPECTED"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
- Ensure a DataContext is used so that the Binding returns true:
public MainWindow()
{
InitializeComponent();
DataContext = new { IsExpected = true };
}
Expected behavior
DataTrigger works correctly and the displayed text is "EXPECTED".
Actual behavior
DataTrigger does not work correctly and the displayed text is "NOT EXPECTED".
Regression?
No response
Known Workarounds
DataTrigger works as expected if at least one of the following conditions is changed:
- Property has a name other than "Value"
- an explicit data type is used for the Value property of the markup extension
- an explicit data type is used for the Value property of the DataTrigger
MichaeIDietrich
Metadata
Metadata
Assignees
Labels
No labels