3

No changes occur when you try to change the font size of the Message property of the InfoBar class with the FontSize property.

Problem

Font size has not changed

Source Code

<InfoBar
   Severity="Warning"
   IsOpen="True"
   FontSize="50"
   Title="Data Requests"
   Message="This is a test. FontSize at 50" >
</InfoBar>

1 Answers1

1

This was a messy workaround that I tried and looks like it works, somehow.

Edited Bar

<InfoBar x:Name="Notification"
    IsOpen="true">
    <InfoBar.Content>
        <TextBlock 
            Text="Hello, world!"
            Margin="0,-50,0,0"
            FontSize="50"
        />
    </InfoBar.Content>
</InfoBar>

You can add custom contents inside your bar. As you can see, I added a TextBlock and applied the changes. It works well with the icon and with the close button. If you want to add more TextBlocks or other Components, you will have to work with the style.

In this example, I created a negative margin on top, so the block could move up, aligned to the bar icon and close button.

  • 1
    Hello, the workaround works! That was not the solution I was looking for as I was trying to fix the FontSize property, it seems to be a WinUI 3 bug. Glad you found a working solution. :) – dressnature Jul 12 '22 at 03:44
  • I forgot to mention - I tried to find the reason why you can't just update FontSize property. I saw the official documentation [here](https://learn.microsoft.com/en-us/windows/apps/design/controls/infobar), but unfortanely there is no reference about adjusting the font size property. I realized that should be a read only visual property and a work around was necessary. Thank you for the reply, and good luck! :) – David Rodrigues Jul 12 '22 at 07:16
  • Thank you, I have already seen the documentary and was a bit confused because I did not have clarity. :) – dressnature Jul 12 '22 at 07:20