QAT cloning woes for User Control

Ribbon for WPF Forum

Posted 8 years ago by Jake Conkerton-Darby
Version: 16.1.0633

I have a UserControl as the content for a SplitButton's Content, which works as intended in the ribbon, but when added to the QAT falls apart. My main issue is the MultiBinding for the ribbon Button not binding correctly in the cloned object. I beleive I should be doing something in the OnCloneCreated event, but I'm not sure what to do within the actual handler, as I've tried a number of things that haven't worked.

The following link contains a .zip file with a basic example of my problem:

Alternatively the entirety of the code is included at the following pastebin, in one single text file:


I would appreciate advice on how to get the QAT version of the SplitButton to work the same as the ribbon version.



I found a small error in my test program, that each version of the popup used a different View Model, all that needs changing is in MainWindow.xaml.cs the line 

PopupContentUCViewModel vm;

 should be replaced by:

private static PopupContentUCViewModel vm;

 Even after chaning this the problem still persists

[Modified 8 years ago]

Comments (2)

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


I believe what's happening is that the binding inside the UserControl might be getting replaced by a fixed value.  I think it's working better if you do something like this where you effectively are creating the UserControl like new:

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

private static void OnCloneCreatedEvent(object sender, DependencyObjectItemRoutedEventArgs e) {
	var originalSplitButton = e.Source as SplitButton;
	var splitButton = e.Item as SplitButton;
	if ((splitButton != null) && (originalSplitButton != null))
		splitButton.PopupContent = new PopupContentUC() { DataContext = ((UserControl)originalSplitButton.PopupContent).DataContext };

This handler would need logic to make sure you're cloning the right thing and when appropriate, etc.

Actipro Software Support

Posted 8 years ago by Jake Conkerton-Darby

Thanks, this seems to have fixed my problem :)

The latest build of this product (v24.1.2) 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.