teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

ButtonListStyleの追加

2015/11/27 04:25

投稿

toshi0607
toshi0607

スコア56

title CHANGED
File without changes
body CHANGED
@@ -8,8 +8,7 @@
8
8
 
9
9
  解決方法のごご教示をお願いします。
10
10
 
11
- ```C#
11
+ ```XAML
12
-
13
12
  <StackPanel Margin="20" VerticalAlignment="Center" DataContext="{Binding Source={StaticResource oHogePage}, Path=Sample}">
14
13
  <ListBox ItemsSource="{Binding}" Height="290" Background="#FFECECEC" BorderBrush="{x:Null}">
15
14
  <ListBox.ItemTemplate>
@@ -26,6 +25,57 @@
26
25
  ```
27
26
 
28
27
 
28
+ また、下記がButtonListStyleの中身です。
29
+ ```XAML
30
+ <SolidColorBrush x:Key="Button.Static.Background" Color="#FFDDDDDD"/>
31
+ <SolidColorBrush x:Key="Button.Static.Border" Color="#FF707070"/>
32
+ <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/>
33
+ <SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/>
34
+ <SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/>
35
+ <SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/>
36
+ <SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/>
37
+ <SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
38
+ <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/>
39
+ <Style x:Key="ButtonListStyle" TargetType="{x:Type Button}">
40
+ <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
41
+ <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
42
+ <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
43
+ <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
44
+ <Setter Property="BorderThickness" Value="1"/>
45
+
46
+ <Setter Property="Padding" Value="1"/>
47
+ <Setter Property="Template">
48
+ <Setter.Value>
49
+ <ControlTemplate TargetType="{x:Type Button}">
50
+ <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
51
+ <StackPanel Orientation="Horizontal">
52
+ <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
53
+ </StackPanel>
54
+ </Border>
55
+ <ControlTemplate.Triggers>
56
+ <Trigger Property="IsDefaulted" Value="true">
57
+ <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
58
+ </Trigger>
59
+ <Trigger Property="IsMouseOver" Value="true">
60
+ <Setter Property="Background" TargetName="border" Value="DarkGray"/>
61
+ <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
62
+ </Trigger>
63
+ <Trigger Property="IsPressed" Value="true">
64
+ <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
65
+ <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
66
+ </Trigger>
67
+ <Trigger Property="IsEnabled" Value="false">
68
+ <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
69
+ <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
70
+ <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
71
+ </Trigger>
72
+ </ControlTemplate.Triggers>
73
+ </ControlTemplate>
74
+ </Setter.Value>
75
+ </Setter>
76
+ </Style>
77
+ ```
78
+
29
79
  ### 動作環境
30
80
  ・ .NET Frame Work 4.5
31
81
  ・Visual Studio2013