Reputation: 10895
I am hosting a Path
inside a Button
and want to dynamically change the Data
property based on the WindowState
of the window that contains the control and thus I ended up with the following XAML code:
<Path SnapsToDevicePixels="True" Data="F1M0,0L0,9 9,9 9,0 0,0 0,3 8,3 8,8 1,8 1,3z"
Fill="Black">
<Path.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type system:Window}}, Path=WindowState}" Value="Maximized">
<Setter Property="Data" Value="F1M0,10L0,3 3,3 3,0 10,0 10,2 4,2 4,3 7,3 7,6 6,6 6,5 1,5 1,10z M1,10L7,10 7,7 10,7 10,2 9,2 9,6 6,6 6,9 1,9z" />
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
Unfortunately I get the error message The member "Data" is not recognized or is not accesible.
and I did not understand why this error occurs and neither was I able to find a workaround.
Upvotes: 0
Views: 216
Reputation: 35723
you are missing TargetType
.
also note that if you set local value for Data
, then a setter from trigger won't be able to change it, so you need a setter in a style
<Path SnapsToDevicePixels="True" Fill="Black">
<Path.Style>
<Style TargetType="Path">
<Setter Property="Data" Value="F1M0,0L0,9 9,9 9,0 0,0 0,3 8,3 8,8 1,8 1,3z"/>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type system:Window}}, Path=WindowState}" Value="Maximized">
<Setter Property="Data" Value="F1M0,10L0,3 3,3 3,0 10,0 10,2 4,2 4,3 7,3 7,6 6,6 6,5 1,5 1,10z M1,10L7,10 7,7 10,7 10,2 9,2 9,6 6,6 6,9 1,9z" />
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
Upvotes: 1