我需要在頂行對(duì)齊兩個(gè)不同字體大小的文本元素。到目前為止,我所管理的就是:由此代碼產(chǎn)生: <Canvas VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="True"> <StackPanel x:Name="RemainingTimeDisplay" Orientation="Horizontal" VerticalAlignment="Top"> <StackPanel.Margin> <MultiBinding Converter="{StaticResource CenterConverter}"> <Binding ElementName="RemainingTimeDisplay" Path="ActualWidth"/> <Binding ElementName="RemainingTimeDisplay" Path="ActualHeight"/> </MultiBinding> </StackPanel.Margin> <!--<Run FontSize="360" Text="{Binding RemainingTime.Minutes, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, StringFormat=D2, Converter={StaticResource IntAbsConverter}}"/> <Run FontSize="128" Text="{Binding RemainingTime.Seconds, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, StringFormat=D2, Converter={StaticResource IntAbsConverter}}"/>--> <TextBlock FontSize="360" Text="{Binding RemainingTime.Minutes, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, StringFormat=D2, Converter={StaticResource IntAbsConverter}}"/> <TextBlock FontSize="128" Text="{Binding RemainingTime.Seconds, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, StringFormat=D2, Converter={StaticResource IntAbsConverter}}"/> </StackPanel> </Canvas>或者:我還嘗試了更多的東西,我不會(huì)在代碼中重復(fù)。我嘗試將“運(yùn)行”用作兩個(gè)文本元素的單個(gè) TextBlock 的子元素,并且我(實(shí)際上開始)嘗試不使用包含其他兩個(gè)的 TextBlock。所以我嘗試了很多,我搜索了很多 - 但我仍然不是我想去的地方。
1 回答

天涯盡頭無(wú)女友
TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個(gè)贊
嘗試以下操作:
<TextBlock FontSize="360"
Text="00"
LineHeight="360"
LineStackingStrategy="BlockLineHeight" />
<TextBlock FontSize="128"
LineHeight="360"
LineStackingStrategy="BlockLineHeight">
<Run Text="00" BaselineAlignment="Top" />
</TextBlock>
- 1 回答
- 0 關(guān)注
- 294 瀏覽
添加回答
舉報(bào)
0/150
提交
取消