问题
Let's say I have two viewboxes with two textblocks inside them. They both have the same Width and Height, but the text won't be the same length. How could I make them have the same font size, regardless of the number of characters?
Code example:
<Viewbox x:Name="vb1">
<TextBlock Text="Some text" />
</Viewbox>
<Viewbox x:Name="vb2">
<TextBlock Text="Some bigger text" />
</Viewbox>
Here's what I would like:

回答1:
Place both TextBlock
controls in the same ViewBox
:
<Viewbox>
<Grid>
<TextBlock Text="Some text" />
<TextBlock Text="Some bigger text" />
</Grid>
</Viewbox>
What Mike Strobel said makes sense; I'm not sure if you want to overlap the text or not. If not, then replace the Grid
with a StackPanel
to get an effect like this:

To place them side-by-side, you could play around with a Grid
and setting column widths... YMMV. I'm not sure what else to suggest because I'm not exactly sure what you're trying to achieve.
<Viewbox>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="300" />
</Grid.ColumnDefinitions>
<TextBlock Text="Some text" />
<TextBlock Text="Some bigger text" Grid.Column="1" />
</Grid>
</Viewbox>
来源:https://stackoverflow.com/questions/26609703/setting-the-same-font-size-across-multiple-viewboxes