在Radio Button的XAML中換行:

huangapple go评论56阅读模式
英文:

Line Break in Radio Button xaml

问题

我在C#中遇到一个单选按钮内容的问题。因为内容太长,需要换行。

我尝试使用"&#xa"进行换行,但不起作用。
这是我的XAML:


<details>
<summary>英文:</summary>

i have a Problem in c# with the content of a radio button.
Because the Content is to long for one Line i need a Line break.

I&#39;ve tried to do the LineBrek with &quot;&amp;#xa&quot; but it&#39;s not working...
Thats my xaml:

<RadioButton x:Name="RbMitarbeiterNicht" Grid.ColumnSpan="2"
HorizontalAlignment="Left" Height="20" Margin="863,929,0,0"
VerticalAlignment="Top"
GroupName="rb_stoerung"
Content="Mitarbeiter nicht anwesend"
FontSize="16" Width="102" Foreground="#000000"
Background="#FFFFFF" Checked="RbMitarbeiterNicht_Checked"/>


</details>


# 答案1
**得分**: 0

也许您使用了`&amp;#xa`而不是`&amp;#x0a;`,后者是换行的Unicode字符。

如果不是这种情况,而是问题中存在拼写错误,那么我建议使用`TextBlock`来显示内容。

```xml
<RadioButton x:Name="RbMitarbeiterNicht" Grid.ColumnSpan="2"
            HorizontalAlignment="Left" Height="20" Margin="863,929,0,0"
            VerticalAlignment="Top"
            GroupName="rb_stoerung"
            FontSize="16" Width="102" Foreground="#000000"
            Background="#FFFFFF" Checked="RbMitarbeiterNicht_Checked">
   <RadioButton.Content>
       <TextBlock Text="Line 1 &#x0a;Line 2">
   </RadioButton.Content>
</RadioButton>
英文:

Maybe you have used &amp;#xa instead of &amp;#x0a; which is the line break unicode character.

If this is not the case and there is typo in the question then I suggest using a TextBlock for content.

&lt;RadioButton x:Name=&quot;RbMitarbeiterNicht&quot; Grid.ColumnSpan=&quot;2&quot;
         HorizontalAlignment=&quot;Left&quot; Height=&quot;20&quot; Margin=&quot;863,929,0,0&quot;
         VerticalAlignment=&quot;Top&quot;
         GroupName=&quot;rb_stoerung&quot;
         FontSize=&quot;16&quot; Width=&quot;102&quot; Foreground=&quot;#000000&quot;
         Background=&quot;#FFFFFF&quot; Checked=&quot;RbMitarbeiterNicht_Checked&quot;&gt;
    &lt;RadioButton.Content&gt;
        &lt;TextBlock Text=&quot;Line 1 &amp;#x0a;Line 2&quot;&gt;
    &lt;/RadioButton.Content&gt;
&lt;/RadioButton &gt;

huangapple
  • 本文由 发表于 2023年6月1日 16:03:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76379845.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定