Reputation: 193
I’m using WinUI 3 with C#. When I set a Margin on an InfoBar, the margin remains even when the InfoBar is hidden. Is there a way to make the margin disappear when the InfoBar is not visible? Or is this not possible?
<Grid Width="400">
<StackPanel>
<TextBlock>Message</TextBlock>
<InfoBar IsOpen="True" Severity="Error" Margin="0,50,0,0" Message="MessageMessageMessage"/>
<TextBlock>Message2</TextBlock>
</StackPanel>
</Grid>
Upvotes: 0
Views: 39
Reputation: 13666
You can switch switch Visibility
like this:
<StackPanel>
<TextBlock>Message</TextBlock>
<InfoBar x:Name="InfoBarControl"
Margin="0,50,0,0"
IsOpen="{x:Bind Toggle.IsOn, Mode=OneWay}"
Message="MessageMessageMessage"
Severity="Error"
Visibility="{x:Bind InfoBarControl.IsOpen, Mode=OneWay}" />
<TextBlock>Message2</TextBlock>
</StackPanel>
Upvotes: 1