Hi,Using 2009.2 with SR# 2078:When I add a ComboEditorTool to the QAT, the "SelectedItemChanged" event of the ComboEditorTool is raised - that is WITHOUT having changed the selected item in the process (not sure how I'd do that anyway.) In the event args, e.OldValue is set to Nothing, even though there was a value selected there before the ComboEditorTool was added to the QAT.Is there a reason why SelectedItemChanged is raised when adding a ComboEditorTool to the QAT, or is it a bug?Thanks,Michel
Hi Andrew,
I didn't think of that - makes sense.
I've added your code snippet and it does the trick. Thanks!
Michel
When you add a tool to the qat a clone of the orignal tool is created including copying the event handlers of that tool. Then select properties of the clone are bound to properties of the source tool. I'm guessing that since some properties like the selectedindex, value, etc. are bound it is at that point that the property is being initialized and you are seeing the event. The best thing to do is to probably ignore that event when the e.OriginalSource is not the source tool. e.g.
private void ComboEditorTool_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e){ if (XamRibbon.GetOriginalTool(e.OriginalSource as FrameworkElement) != e.OriginalSource) return; // do something bool t = true;}
// do something bool t = true;}