简体   繁体   English

仅更改MenuItem单选按钮和复选框

[英]Change only MenuItem Radiobutton and Checkbox

for separator it is possible, to change only this, which are included in MenuItem. 对于分隔符,可以仅更改它,它包含在MenuItem中。 therefor I had to use: 为此,我不得不使用:

<Style TargetType="{x:Type Separator}" x:Key="{x:Static MenuItem.SeparatorStyleKey}">

is there some thing like this for menuitem and RadioButton? menuitem和RadioButton是否有类似的东西? the other problem is, that this only works correctly under windows7 and not under windows XP. 另一个问题是,这只能在Windows7下正常运行,而不能在Windows XP下正常运行。 I Post the whole Code later, but i had not to specify the separator with the key. 我稍后再发布整个代码,但是我不必使用键指定分隔符。 it works so - under windows7. 它的工作原理-在Windows7下。 at windows xp the color is changed to, but a strange transparent border is about the whole seperator. 在Windows XP中,颜色更改为,但是整个分隔符周围都有一个奇怪的透明边框。 But i draw only 1 border for fill it with the color in my separator control template and not two! 但是我只画了1个边框,用分隔符控制模板中的颜色填充它,而不是两个!

can i find somewhere the child-"stylekey"'s for MenuItem? 我可以在某处找到MenuItem的子“样式键”吗? vs has at this point no intelligence. vs目前没有情报。

here is the full code: 这是完整的代码:

<Style TargetType="{x:Type Separator}" x:Key="{x:Static MenuItem.SeparatorStyleKey}">
    <Setter Property="Background" Value="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Menu}}}"/>
    <Setter Property="Focusable" Value="false"/>
    <Setter Property="OverridesDefaultStyle" Value="True" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Separator}">
                    <Border Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="True" 
                            Height="2"/>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

the problem with windows xp was, that i has not override the default style. Windows XP的问题是,我还没有覆盖默认样式。

the other question with the radio buttons and checkbox is always there 带有单选按钮和复选框的另一个问题始终存在

an other problem is, that i had to override the default style for a grid'S background. 另一个问题是,我不得不覆盖网格背景的默认样式。 i had to draw a line at the grid's background with a color and include the default content. 我必须在网格的背景上用颜色绘制一条线,并包括默认内容。 the line should not added manually at each window, the should be at the same position at each window of the application. 该行不应在每个窗口中手动添加,该行应位于应用程序每个窗口中的相同位置。

but the line should only be a line and not fill the whole window, i don't know the width and high of the window. 但是这条线只能是一条线,不能填满整个窗口,我不知道窗口的宽度和高度。 can i maybe use the ? 我可以使用吗? is there any example? 有什么例子吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM