
Hello,
I have prepared a very trimmed-down example with only one button in the application menu:
The button's label property has a data binding to "Button1Text" property. If you click on the button, the property "Button1Text" is changed and the event "PropertyChanged" is fired. Now in the menu you can see, the button has a new label.
But if you add the button the the Quick Access Tool Bar (QAT) at runtime, further clicks on the button in the application menu do NOT UPDATE the button's label in the QAT (only in the menu)!!! (Clicks on QAT button do not work either.)
Could you please show me how to implement CloneService.CloneCreatedEvent, so that the QAT-Button does exactly the same as the original button?
Is there a common/universal implementation for CloneCreatedEvent? I do not want to handle every button individually, if I have button's with different property bindings / event handler / ...
Many thanks!
MainWindow.xaml:
<ribbon:RibbonWindow
x:Class="RibbonExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:ActiproSoftware.Windows.Controls.Ribbon;assembly=ActiproSoftware.Ribbon.Wpf351" xmlns:Controls="clr-namespace:ActiproSoftware.Windows.Controls.Ribbon.Controls;assembly=ActiproSoftware.Ribbon.Wpf351" Title="MainWindow" Height="350" Width="525">
<ribbon:Ribbon Name="myRibbon">
<ribbon:Ribbon.ApplicationMenu>
<Controls:ApplicationMenu>
<Controls:Button Id="Button1" Label="{Binding Button1Text}" Click="Button_Click">
</Controls:Button>
</Controls:ApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
<ribbon:Ribbon.QuickAccessToolBarItems>
</ribbon:Ribbon.QuickAccessToolBarItems>
</ribbon:Ribbon>
</ribbon:RibbonWindow>
MainWindow.xaml.cs:
using System.ComponentModel;
namespace RibbonExample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : INotifyPropertyChanged
{
public MainWindow()
{
InitializeComponent();
Button1Text = "Button1";
myRibbon.DataContext = this;
}
public string Button1Text { get; set; }
private void Button_Click(object sender, ActiproSoftware.Windows.Controls.Ribbon.Controls.ExecuteRoutedEventArgs e)
{
Button1Text = Button1Text + "*";
PropertyChanged(this, new PropertyChangedEventArgs("Button1Text"));
}
public event PropertyChangedEventHandler PropertyChanged;
}
}