QAT cloning woes for User Control

Ribbon for WPF Forum

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

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:

https://drive.google.com/file/d/0B7EiULWd_OKbSEV0WWtmRzdYTlU/view?usp=sharing

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

http://pastebin.com/vZqFGHyc

 

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

 

Edit:

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
Avatar

Hello,

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
Avatar

Thanks, this seems to have fixed my problem :)

The latest build of this product (v24.1.3) was released 26 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.