Error in nested RibbonApplicationMenuItem

不羁岁月 提交于 2019-12-05 06:19:40

This is very easy to understand and to fix, but there is no real need to do that.

The Reason

The issue is that in the standard ribbon templates there are many wrong placeholders

<Condition Binding="{Binding  (0)}" Value="True"/>

The Fix

Long story short, you need to change the above into, for example:

<Condition Binding="{Binding  Zero }" Value="True"/>

How to do that?

That's not trivial, but you can do it with a little of attention..

You have to add a reference to PresentationFramework.Classic

Then, let me start from the end... the objective is defining the following

<Window.Resources>
    <Style TargetType="{x:Type RibbonButton}" >
        <Setter Property="Template" Value="{DynamicResource RibbonButtonControlTemplate1}"/>
    </Style>

    <Style TargetType="{x:Type RibbonApplicationSplitMenuItem}" >
        <Setter Property="Template" Value="{DynamicResource RibbonApplicationSplitMenuItemControlTemplate1}"/>
    </Style>


    <Style TargetType="{x:Type RibbonApplicationMenuItem}" >
        <Setter Property="Template" Value="{DynamicResource RibbonApplicationMenuItemControlTemplate1}"/>
    </Style>

</Window.Resources>

The missing control templates

What is still missing? Three very big pieces of code containing the above ControlTemplates... but there is a trick to include them:

  • move the cursor to (for example) RibbonApplicationMenuItem and locate the Template in the Properties Window
  • click on the right Ambient and select Convert to New Resource...

    In conclusion you will run an overall replace from (0) to Zero through all of your xaml.

Again, this is intended as a pure academic exercise.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!