All my grids could be small and very big depending on window size but text inside is looking really small on big grid sizes.
My current idea (but I don’t know how to realize it yet) is to make Binding for all Grid elements to single font and then change the font size by
override void OnRender(DrawingContext dc) {
depending on window size.
The question is: Is this idea sane and is there other methods for it?
If you have not set the font on inner elements explicitly, they inherit the parent font. So you can change the font size on one of the parent elements (for example the
Windowitself or theGrid). This changes the font size on all inner elements that has not specified the font size explicitly.However if your font should be of different sizes, the best solution in my opinion is binding the font size of elements to the font size of the parent window, and using a value converter to do a scale on the font size:
Define a value converter like this:
And use it in your xaml:
ConverterParameteris used as the scale of the element’s font related to the window (specified inElementNameproperty of the binding).In this example font of the first
TextBlockis 150% of the window font and font of the secondTextBlockis 70% of the window. The thirdTextBlockfollows the font size of the window.