简体   繁体   中英

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. (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. (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 .

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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