I have a Grid which contains a Scrollviewer. I would like to change the Grid's margin if the Vertical scrollbar is visible.
<Grid x:Name="TopGrid" Margin="50,10,100,10" Background="Gainsboro" >
<ScrollViewer x:Name="sv" VerticalScrollBarVisibility="Auto">
<TextBlock x:Name="ItemText" Text="Description" />
</ScrollViewer>
</Grid>
The DataTrigger condition in Scrollviewer should be this:
<DataTrigger Binding="{Binding ComputedVerticalScrollBarVisibility,
ElementName=sv}" Value="Visible">
</DataTrigger>
and the grid's style should be changed to this:
<Setter TargetName="TopGrid" Property="Margin" Value="100"/>
How can I have the data trigger binding on Scrollviewer and change the style of the parent grid?
Thanks
If you want to change
Grid.Marginbased on some condition you could createStyleforGridwithTriggeryou posted but you need to move defaultMarginvalue intoSetterotherwiseDataTriggerwon't be able to change that value