【问题标题】:Button Border being cut off in XAML/C#按钮边框在 XAML/C# 中被切断
【发布时间】:2015-01-22 07:39:37
【问题描述】:

我正在使用 Visual Studio Community 2013 在 XAML/C# 中设计一个 Windows Phone 8.1 应用程序,并且我正在使用几个按钮。出于某种原因,当我将应用程序部署到手机时,一些按钮边框被切断了。以下是相关代码:

    <Grid.ColumnDefinitions>
            <ColumnDefinition Width="11*"/>
            <ColumnDefinition Width="11*"/>
            <ColumnDefinition Width="11*"/>
            <ColumnDefinition Width="11*"/>
        </Grid.ColumnDefinitions>

<Button x:Name="MiddleButton" HorizontalAlignment="Stretch" Margin="10,0" VerticalAlignment="Bottom" Height="140" Background="#FF25A618" FontSize="22" ClickMode="Press" BorderBrush="#FF856767" Foreground="White" Content="2" FontFamily="Global User Interface" Grid.ColumnSpan="2" Grid.Column="1" Padding="0"/>
        <Button x:Name="RightButton" Content="3" HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Bottom" Height="140" Background="#FF0686A2" FontSize="22" ClickMode="Press" BorderBrush="#FF856767" FontFamily="Global User Interface" Grid.Column="3" Padding="0"/>
        <Button x:Name="LeftButton" Content="1" HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Bottom" Height="140" Background="#FFCB0B0B" FontSize="22" ClickMode="Press" BorderBrush="#FF856767" FontFamily="Global User Interface" Padding="0" UseLayoutRounding="True"/>

我尝试更改按钮的 Horizo​​ntalAlignment 属性,并更改边距,以便在按钮和屏幕两侧之间留出更多空间,但 LeftButton 和 RightButton 的至少一个边框总是被切断.使用这些对齐属性,每个按钮的右边框被切断。 是什么导致边界被切断,我该如何解决?

【问题讨论】:

    标签: c# xaml windows-phone-8.1


    【解决方案1】:

    按钮在其默认样式中定义了 MinWith

    <Setter Property="MinWidth" Value="{ThemeResource PhoneButtonMinWidth}"/>
    

    这被定义为 109,因此比网格中的空间大:

    <x:Double x:Key="PhoneButtonMinWidth">109</x:Double>
    

    只需为匹配您的内容设置一个新的 MinWidth

    <Button MinWidth="10" ... />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-15
      • 1970-01-01
      • 2012-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多