Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Binding="{Binding (0)}" mean?

I found this:

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

triggers in RibbonMenuButton template. What does it mean? I've tried to google, but found nothing.

UPD more code:

<ControlTemplate x:Key="RibbonMenuButtonControlTemplate1" TargetType="{x:Type RibbonMenuButton}">
...
    <DataTrigger Binding="{Binding (0)}" Value="True">
        <Setter Property="TextElement.Foreground" TargetName="MainGrid" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
        <Setter Property="PathFill" TargetName="TwoLineText" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
        <Setter Property="CornerRadius" TargetName="OuterBorder" Value="0"/>
        <Setter Property="Background" TargetName="OuterBorder" Value="Transparent"/>
        <Setter Property="BorderBrush" TargetName="OuterBorder" Value="Transparent"/>
    </DataTrigger>
...

This code created in Blend after "edit template" button pressed on RibbonMenuButton control.

like image 569
Mikhail Gubanov Avatar asked Feb 19 '14 11:02

Mikhail Gubanov


2 Answers

It looks like a bug. As far as I know, in WPF can not be Binding of this type. Below is a list of deficiencies, please pay attention to the first paragraph, quoted from connect.microsoft.com (archive):

I'm trying to style the ribbon control (System.Windows.Controls.Ribbon) and I keep running into problems.

  • If I use Blend or another tool to copy the default template of the Ribbon, the RibbonGroup, the RibbonTab, etc. these templates have errors. There are Bindings like {Binding (0)}.

  • I cannot change the height of the ribbon control.

  • It's not possible to change the template of the RibbonGroup, to change the appearance of the separator and to place the header in the top left corner of the group.

  • It's not possible to add a label to the ApplicationMenuButton. Furthermore this button has a fixed width.

  • I can't manage to remove the borders at the bottom of the ribbon control.

As I understand it, there is no hotfix.

like image 114
Anatoliy Nikolaev Avatar answered Oct 26 '22 17:10

Anatoliy Nikolaev


The only time this can appear is in the tokenized path format. See the code examples under "Indirect Targeting" in the Storyboards Overview. In XAML code, however, it's invalid. I imagine what happened was something like this:

// something goes wrong here, and GetProperties returns an empty array
var propertyChain = GetProperties();

var path = new PropertyPath("(0)", propertyChain);

trigger.Binding = new Binding { Path = path };

With an empty PathParameters, the XAML generator might then dump the raw tokenized path.

like image 33
nmclean Avatar answered Oct 26 '22 19:10

nmclean