Application Menu broken :(

Ribbon for WPF Forum

Posted 9 years ago by SledgeHammer01
Version: 10.1.0522
Platform: .NET 4.0
Environment: Windows XP (32-bit)
Avatar
This *was* working... not sure what version it broke in, but had to be pretty recent. Was also broken in 520. Thats the earliest one I have.

My main window is named "mainWindow":

<ribbon:RibbonWindow ... Name="mainWindow" ... />

Here are two buttons in my Application Menu:

<ribbon:Button Id="Save" Command="ApplicationCommands.Save" KeyTipAccessText="S" IsEnabled="{Binding ElementName=mainWindow, Path=IsTemplateSetLoaded}" />

<ribbon:Button Id="SaveAs" Command="ApplicationCommands.SaveAs" KeyTipAccessText="A" IsEnabled="{Binding ElementName=mainWindow, Path=IsTemplateSetLoaded}" />

Here is my property registration:

private static readonly DependencyPropertyKey IsTemplateSetLoadedProperty = DependencyProperty.RegisterReadOnly("IsTemplateSetLoaded",
typeof(bool), typeof(MainWindow), new PropertyMetadata(false));

I have made sure I'm not setting IsTemplateSetLoadedProperty anywhere. So its value is false.

Neither command is disabled in the Application menu. If I hardcode IsEnabled="False", they are disabled. If I give the buttons names and set IsEnabled=false; via code, that works too. Just not the data binding.

I'm using the classic ribbon, but it doesn't work with the scenic layout either.

P.S. I have a few buttons in the ribbon itself that use the same exact binding, and those work fine. So it is specific to the application menu.


[Modified at 06/04/2010 07:10 PM]

Comments (3)

Posted 9 years ago by SledgeHammer01
Avatar
Ok, I just noticed when I start my app in the debugger, I get the following:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=mainWindow'. BindingExpression:Path=IsTemplateSetLoaded; DataItem=null; target element is 'Button' (Name='btnSave'); target property is 'IsEnabled' (type 'Boolean')

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=mainWindow'. BindingExpression:Path=IsTemplateSetLoaded; DataItem=null; target element is 'Button' (Name=''); target property is 'IsEnabled' (type 'Boolean')

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=mainWindow'. BindingExpression:Path=IsTemplateSetLoaded; DataItem=null; target element is 'Button' (Name=''); target property is 'IsEnabled' (type 'Boolean')

These are the 3 buttons in the Application Menu that use the binding.

As indicated above, there are 3 additional buttons in the ribbon itself that use this binding and it works fine.

I also set a breakpoint and the static IsTemplateSetLoadedProperty is getting hit before the 3 exceptions, also, I can call SetValue() before the 3 exceptions as well.
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hello... For questions like this that require a repro, please always put together a simple sample project that shows the issue and email that to our support address. Don't include any .exe files in your ZIP. Please reference this forum post in your e-mail. Thanks!


Actipro Software Support

Posted 9 years ago by SledgeHammer01
Avatar
sent
The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.