简体   繁体   English

Expression Blend中的WPF按钮文本

[英]Wpf button text in Expression Blend

Normally, If i use the button in C# Windows form, and if the button text is too long, it will go to next line. 通常,如果我在C#Windows窗体中使用按钮,并且按钮的文本太长,它将转到下一行。 (Eg. Very Happy, Happy will go to next line). (例如,非常高兴,高兴会转到下一行)。 But When i use wpf app in expression blend, the text will be truncated even though i set the auto size to false. 但是,当我在表达式混合中使用wpf应用程序时,即使我将自动大小设置为false,文本也会被截断。 (Eg. Very Happy, Happy will be truncated). (例如,非常开心,开心会被截断)。 Any advice would be really appreciated. 任何建议将不胜感激。 Thank you. 谢谢。

You need to place a TextBlock inside your button and set the TextWrapping attribute to Wrap . 您需要在按钮内放置一个TextBlock并将TextWrapping属性设置为Wrap

Example: 例:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="WpfApplication1.MainWindow"
    x:Name="Window"
    Title="MainWindow"
    Width="640" Height="480">

    <Grid x:Name="LayoutRoot">
        <Button HorizontalAlignment="Left" VerticalAlignment="Top" Width="40" Height="40">
            <TextBlock Text="Very Happy" TextWrapping="Wrap" />
        </Button>
    </Grid>
</Window>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM