回答編集履歴

1

見直しキャンペーン中

2023/07/26 15:49

投稿

TN8001
TN8001

スコア9326

test CHANGED
@@ -1,107 +1,54 @@
1
1
  > 動作には問題ありませんが、バインドエラーを消すにはどうすればいいのかご教授ください。
2
-
3
-
4
2
 
5
3
  確かにそのようになりますね。
6
4
 
7
-
8
-
9
5
  「動いてるならいいじゃん」という気もしますが、リソース経由でバインドすれば消えました(細かい理由は知りません)
10
-
11
6
  [wpf - ControlTemplate LayoutTransform Binding System.Windows.Data Error 2 or 4 - Stack Overflow](https://stackoverflow.com/questions/49047739/controltemplate-layouttransform-binding-system-windows-data-error-2-or-4)
12
-
13
-
14
7
 
15
8
  面倒なので`DropShadowEffect`で済ませましたが、おそらく同様かと思います。
16
9
 
17
-
18
-
19
- ```xaml
10
+ ```xml
20
-
21
11
  <ResourceDictionary
22
-
23
12
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
24
-
25
13
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
26
-
27
14
  xmlns:local="clr-namespace:Questions332649">
28
15
 
29
-
30
-
31
16
  <Style TargetType="{x:Type local:Hoge}">
32
-
33
17
  <Setter Property="Template">
34
-
35
18
  <Setter.Value>
36
-
37
19
  <ControlTemplate TargetType="{x:Type local:Hoge}">
38
-
39
20
  <Grid>
40
-
41
21
  <Grid.Resources>
42
-
43
22
  <DropShadowEffect x:Key="effect" ShadowDepth="{Binding Piyo, RelativeSource={RelativeSource TemplatedParent}}" />
44
-
45
23
  </Grid.Resources>
46
-
47
24
  <Border
48
-
49
25
  Background="{TemplateBinding Background}"
50
-
51
26
  BorderBrush="{TemplateBinding BorderBrush}"
52
-
53
27
  BorderThickness="{TemplateBinding BorderThickness}"
54
-
55
28
  Effect="{StaticResource effect}">
56
-
57
29
  <Slider Maximum="100" Value="{Binding Piyo, RelativeSource={RelativeSource TemplatedParent}}" />
58
-
59
30
  </Border>
60
-
61
31
  </Grid>
62
-
63
32
  </ControlTemplate>
64
-
65
33
  </Setter.Value>
66
-
67
34
  </Setter>
68
-
69
35
  </Style>
70
-
71
36
  </ResourceDictionary>
72
-
73
37
  ```
74
38
 
75
-
76
-
77
- ```xaml
39
+ ```xml
78
-
79
40
  <Window
80
-
81
41
  x:Class="Questions332649.MainWindow"
82
-
83
42
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
84
-
85
43
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
86
-
87
44
  xmlns:local="clr-namespace:Questions332649"
88
-
89
45
  Width="800"
90
-
91
46
  Height="450">
92
-
93
47
  <StackPanel>
94
-
95
48
  <local:Hoge
96
-
97
49
  Margin="20"
98
-
99
50
  BorderBrush="HotPink"
100
-
101
51
  BorderThickness="10" />
102
-
103
52
  </StackPanel>
104
-
105
53
  </Window>
106
-
107
54
  ```