3

ボタンの境界線の太さが変わらないのはなぜですか?

境界線の太さを1または100に変更しても、問題ありません。それは同じだ。カスタムテンプレートではなく、スタイルを使用して変更したいと思います。

 <Window x:Class="GUI.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
    <Style x:Key="newYellowButton" TargetType="{x:Type Button}">
        <Setter Property="Width" Value="100"/>
        <Setter Property="Height" Value="100"/>
        <Setter Property="Background">
            <Setter.Value>
                <RadialGradientBrush Center="0.5,0.5" GradientOrigin="0.5,0.5" RadiusX="0.5" RadiusY="0.5" SpreadMethod="Pad" ColorInterpolationMode="SRgbLinearInterpolation">
                    <GradientStop Color="#FFEEEE3B" Offset="0.5" />
                    <GradientStop Color="#FFF0E49A" Offset="1" />
                </RadialGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderThickness" Value="9"/>
        <Setter Property="BorderBrush" Value="Blue" />
        <Setter Property="Padding" Value="-4"/>
    </Style>
</Window.Resources>
<Grid>
    <Button Style="{StaticResource newYellowButton}" Content="Ok"/>
</Grid>

4

1 に答える 1

3

ボタンのControlTemplateを変更することでそれを行うことができます。それらのスタイル、ブラシ、および...をリソース辞書にコピーしてから、必要な値を変更します。

境界線の太さを変更するには、次のコードを見つけて、必要な変更を加えます。

...
<Border 
      x:Name="Border"  
      CornerRadius="2" 
      BorderThickness="1"                             //CHANGE THIS VALUE
      Background="{StaticResource NormalBrush}"
      BorderBrush="{StaticResource NormalBorderBrush}">
      <ContentPresenter 
        Margin="2"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        RecognizesAccessKey="True"/>
</Border>
...
于 2013-03-26T11:50:54.373 に答える