回答編集履歴
1
追記
test
CHANGED
@@ -5,3 +5,61 @@
|
|
5
5
|
こちらのサンプルコードで SimpleButton にスタイルを適用しています。
|
6
6
|
|
7
7
|
これを参考にしてください。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
###追記
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
外部ファイルでのスタイルの適用
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
まずソリューションエクスプローラーで Themes フォルダにリソースディクショナリを作成してください。
|
20
|
+
|
21
|
+
これを Dictionary1.xaml とします。
|
22
|
+
|
23
|
+
Dictionary1.xaml に次のように記載してください。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
```XAML
|
28
|
+
|
29
|
+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
30
|
+
|
31
|
+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
32
|
+
|
33
|
+
xmlns:local="clr-namespace:WpfApp1.Themes">
|
34
|
+
|
35
|
+
<Style TargetType="TextBox">
|
36
|
+
|
37
|
+
<Setter Property="Background" Value="AliceBlue"/>
|
38
|
+
|
39
|
+
</Style>
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
</ResourceDictionary>
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
スタイルを適用する MainWindow.xaml に次のコードを追加してください。
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
```XAML
|
54
|
+
|
55
|
+
<Window.Resources>
|
56
|
+
|
57
|
+
<ResourceDictionary Source="/Themes/Dictionary1.xaml"/>
|
58
|
+
|
59
|
+
</Window.Resources>
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
以上で MainWindow 上のすべての TextBox の背景に AliceBlue が適用されます。
|