Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1485
Adding ComboEditorTool to QAT triggers SelectedItemChanged
posted

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

Parents
  • 54937
    Offline posted

    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;
    }

Reply Children
No Data