如何将文本包装在 UWP 中 ToggleSwitch 的 Header 字段中
How to wrap the text in the Header field of a ToggleSwitch in UWP
我在 UWP 应用程序的设置页面上有一个 ToggleSwitch,我注意到 ToggleSwitch 的页眉文本没有包装它的方法。当我在 phone 模拟器中测试应用程序时,页眉立即离开页面。知道如何使用 TextBlock 使文本换行吗?
<StackPanel Margin="10,0">
<ToggleSwitch Name="toggleOne" Header="Check this on if you want the app to automatically trigger the zombie apocalypse" Margin="10" />
<ToggleSwitch Name="toggleTwo" Header="Short Sample Text" Margin="10" />
</StackPanel>
您可以像这样为 ToggleSwitch 添加 HeaderTemplate
:
<ToggleSwitch
Name="toggleOne"
Margin="10"
Header="Check this on if you want the app to automatically trigger the zombie apocalypse">
<ToggleSwitch.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" TextWrapping="Wrap" />
</DataTemplate>
</ToggleSwitch.HeaderTemplate>
</ToggleSwitch>
我在 UWP 应用程序的设置页面上有一个 ToggleSwitch,我注意到 ToggleSwitch 的页眉文本没有包装它的方法。当我在 phone 模拟器中测试应用程序时,页眉立即离开页面。知道如何使用 TextBlock 使文本换行吗?
<StackPanel Margin="10,0">
<ToggleSwitch Name="toggleOne" Header="Check this on if you want the app to automatically trigger the zombie apocalypse" Margin="10" />
<ToggleSwitch Name="toggleTwo" Header="Short Sample Text" Margin="10" />
</StackPanel>
您可以像这样为 ToggleSwitch 添加 HeaderTemplate
:
<ToggleSwitch
Name="toggleOne"
Margin="10"
Header="Check this on if you want the app to automatically trigger the zombie apocalypse">
<ToggleSwitch.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" TextWrapping="Wrap" />
</DataTemplate>
</ToggleSwitch.HeaderTemplate>
</ToggleSwitch>