kinton
kinton

Reputation: 193

WinUI 3 InfoBar Margin Remains Even When Hidden – How to Remove It?

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

Answers (1)

Andrew KeepCoding
Andrew KeepCoding

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

Related Questions