Tag: WPF

WPF一则

Posted by – 2008/11/28

Button控件的Content内容因为过长而被截断。
可以指定Button的MinWidth属性,内容显示不下,Button会自动变长。

<Window x:Class="WPFSandBox.StretchButtonWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <UniformGrid Rows="4">
        <Button 
            HorizontalAlignment="Left"
            Name="StretchButton"
            MinWidth="80"
            Content="Very Long Label" />
        <TextBlock 
            HorizontalAlignment="Stretch"
            Text="{Binding Path=ActualWidth, ElementName=StretchButton}" />
    </UniformGrid>
</Window>