0

我有一个 ItemsControl 和一个基于 ToggleButton 的 ItemContainerStyle。这在运行时工作得很好,但它会在设计器中产生错误。(所以如果我想使用设计器,我必须将其注释掉)我用后面的代码填充它。使用单选按钮。

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>

亲切的问候。

4

0 回答 0