Posted 14 years ago
by SledgeHammer01
Version: 10.1.0522
Platform: .NET 4.0
Environment: Windows XP (32-bit)
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]
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]