QAT buttons do not work properly after updating to version 2013.1.0583

Ribbon for WPF Forum

Posted 6 years ago by Roger Rong
Version: 13.1.0583
Avatar

Hi there,

These days we updating from version 2010.1.521 to 2013.1.0583. It seems that everything works fine except the QAT:

After a ribbon button is added to the QAT, users clicking it does not trigger the expected operation and the cloned button in QAT does synchronize its enable/disable state with the original button in the ribbon tab.

We use command in the ribbon buttons. Is it possible the commands dependency property is not cloned properly in the new version? Following is a sample ribbon button in our app.

<ribbon:Button Command="{Binding CallDialCommand}" ImageSourceLarge="../Images/CallDial.ico" MinWidth="50" ImageSourceSmall="../Images/CallDial.ico" Label="Dial" KeyTipAccessText="D" ScreenTipDescription="Call dial. Shortcut Keys: Ctl+L" />

 By the way, in our application the Ribbon window works as a host parent window who contains the parent ribbon and the application menu items inside it. Other ribbon tabs/buttons (for example the above CallDial ribbon button) are added by some plugins loaded by the host at run time. The application menu items cloned to the QAT still work fine, while, those buttons added at run time stop working in the version 2013.1.0583.

Thanks,

Roger

Comments (10)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Roger,

If you'd like us to look into it, please make a new simple sample project that just shows this issue and email that to our support address.  We can go through the various versions to see when something changed that might have caused this.  Please reference this thread in your email and rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 6 years ago by Roger Rong
Avatar

Thanks for the responce. The sample code has sent to <support@actiprosoftware.com>.

Our further investigation found that, when the ribbon buttons are created in other places than the main window, their DataContext will be changed to that of the main window after it is cloned to the QAT, which could cause the buttons in the QAT losing their binding commands.

Thanks,

Roger

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Roger,

Thanks for the sample. That makes sense since at that point (when the button enters the QAT), it's binding is still the same but the DataContext being inherited down has changed due to the visual ancestor change.  Thus the binding doesn't resolve to a command.

I did some research and found that it was the updates in 2010.2 that caused the behavior change.  Namely, ths item:

Improved the CloneService to clone bindings made on dependency properties.

Prior to that, bound items would get their resolved values cloned with them instead of retaining the bindings.

You probably want to attach to some of the CloneService events like CloneCreated and in that, update the binding.  Alternatively you could set the DataSource of each clonable button, but that's probably not as attractive of an option.


Actipro Software Support

Posted 6 years ago by Hejian Lin
Avatar

Then what we can expect in the future? It will be treated as an issue and be fixed at some stage? or we need to find workaround for solving it?

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Hejian,

Well the behavior prior to 2012.2 was actually a bug so how it is working now is how it's intended to be.  If you wish to persist an MVVM binding that requires an inherited DataContext then you'd need to handle it via one of the ways described above.


Actipro Software Support

Posted 6 years ago by Roger Rong
Avatar

>>You probably want to attach to some of the CloneService events like CloneCreated and in that, update the binding.

>>Alternatively you could set the DataSource of each clonable button, but that's probably not as attractive of an option.

 

Thanks for the updating. Can we have a sample to use the CloneService events like CloneCreated to modify the datacontext of a ribbion button?

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Roger,

Check out the CustomizingQat QuickStart since that shows an example of handling the CloneCreated event.  Its event handler just writes to an event list in the UI but in your code, you would copy properties over as appropriate.  e.Item will have the clone and e.OriginalSource will have the source.  So you could just set the DataContext on the e.Item and it will likely work in your scenario.


Actipro Software Support

Posted 6 years ago by Roger Rong
Avatar

Thanks it works. Here is the code in case anyone else needs to the do the similar thing:

 

    EventManager.RegisterClassHandler(typeof(MainWindow), CloneService.CloneCreatedEvent, new EventHandler<DependencyObjectItemRoutedEventArgs>(OnCloneCreatedEvent));
            
...
...


private static void OnCloneCreatedEvent(object sender, DependencyObjectItemRoutedEventArgs e)
{
    ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)e.Item).DataContext = ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)e.Source).DataContext;

}
Posted 6 years ago by Owen Christensen - Software Engineer, Minitab Inc.
Avatar

Along these same lines, when the Ribbon is placed in a Template (Control or Data) the QAT clone fails to copy anything except the container itself:

<ribbon:RibbonWindow x:Class="RibbonInTemplateSample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon" Title="MainWindow" Height="350" Width="525">
    <ribbon:RibbonWindow.Resources>
        <DataTemplate x:Key="RibbonTemplate">
            <ribbon:Ribbon>
                <ribbon:Tab Label="Tab">
                    <ribbon:Group Label="Group">
                        <ribbon:StackPanel>
                            <ribbon:Button Label="Btn1" />
                            <ribbon:Button Label="Btn2" />
                            <ribbon:Button Label="Btn3" />
                        </ribbon:StackPanel>
                    </ribbon:Group>
                </ribbon:Tab>
            </ribbon:Ribbon>
        </DataTemplate>
    </ribbon:RibbonWindow.Resources>
    <ContentPresenter ContentTemplate="{StaticResource RibbonTemplate}" />
</ribbon:RibbonWindow>

Is this a bug?  We want do this because we'd like to use DataTriggers within the RIbbonWindow xaml to control some very complicated layout rules and setters using TargetName are only available within Template triggers.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Owen,

If you'd like us to look at a particular scenario, please make as bare bones of a sample as you can that shows the issue and send that to our support address.  Please rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.