Quantcast
Channel: Ribbon for WPF - Recent Posts
Viewing all articles
Browse latest Browse all 1458

Re: QAT cloning woes for User Control

$
0
0

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.


Viewing all articles
Browse latest Browse all 1458

Trending Articles