ToggleButton に基づく ItemContainerStyle を持つ ItemsControl があります。これは実行時に問題なく動作しますが、デザイナーでエラーが発生します。(したがって、デザイナーを使用する場合はコメントアウトする必要があります) これに分離コードを入力します。ラジオボタンの使用。
InvalidOperationException: タイプ 'RadioButton' 用のスタイルをタイプ 'ContentPresenter' に適用できません。
私はこれで長い間生きてきましたが、解決策があるかどうかを確認する時が来ました!
これを回避する方法はありますか?
<ItemsControl x:Name="BrushButtons"
Grid.Row="1"
Grid.Column="3"
VerticalAlignment="Bottom">
<ItemsPanelTemplate>
<StackPanel VerticalAlignment="Bottom" Orientation="Vertical" />
</ItemsPanelTemplate>
<ItemsControl.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type ToggleButton}}" TargetType="{x:Type RadioButton}">
<Setter Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="-90" />
</Setter.Value>
</Setter>
<Setter Property="Width" Value="70" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
敬具。