简体   繁体   English

XAML / C#中的按钮边框已被切断

[英]Button Border being cut off in XAML/C#

I'm designing a Windows Phone 8.1 app in XAML/C# with Visual Studio Community 2013, and I'm using a few buttons. 我正在使用Visual Studio Community 2013在XAML / C#中设计Windows Phone 8.1应用程序,并且使用了一些按钮。 For some reason, a few of the button borders are getting cut off when I deploy the app to my phone. 出于某种原因,当我将应用程序部署到手机时,一些按钮边框被切断了。 Here's the relevant code: 以下是相关代码:

    <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"/>

I've tried changing the HorizontalAlignment properties of the buttons, and changing the margins so there is more space in between the buttons and the sides of the screen, but at least one border of the LeftButton and the RightButton always gets cut off. 我尝试过更改按钮的Horizo​​ntalAlignment属性,并更改页边距,以便在按钮和屏幕的两边之间有更多的空间,但是LeftButton和RightButton的至少一个边框总是被切除。 With these alignment properties, the right border of each button is cut off. 使用这些对齐属性,每个按钮的右边框将被切除。 What is causing the borders to be cut off, and how do I fix this? 是什么导致边界被切断,我该如何解决?

The Button has a MinWith defined in it's default Style: 该按钮的默认样式中定义了一个MinWith

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

That is defined as 109 and therefore bigger than the space in your Grid: 定义为109 ,因此大于网格中的空间:

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

Just set a new MinWidth for that matches your content. 只需为与您的内容匹配的新MinWidth设置即可。

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

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

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