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
873
'Add or remove Buttons' event
posted

Hello,

with the XamOutlookBar I can use 'Add or remove Buttons' (found in the 'Cofigure Buttons' context menu) to control the visibility of the groups.

Does the XamOutlookBar expose some event that I could listen to, in order to react on hiding/showing groups?

What I want to achieve is the following: If the user hides the currently selected group, I want to automatically select the first visible group.

 

Thanks and best regards,

Rainer

  • 8576
    Verified Answer
    Offline posted

    Hi Rainer -

    There is no event exposed by the XamOutlookBar that is raised when an OutlookBarGroup's Visibility is changed.  However what you could do is override the metadata for the OutlookBarGroup's Visibility property and specify a PropertyChangedCallback.  In there you coul have logic to determine if the currently selected group is being Collapsed and then select the group of your choice.  Here is some sample code that shows how to do that:

     

     

    // Static constructor of your app's main window.

     

    static Window1()

    {

     

    // Override the property metadata for the OutlookBarGroup's Visibility property and specify a

     

    // PropertyChangedCallback.

    Infragistics.Windows.OutlookBar.

    OutlookBarGroup.VisibilityProperty.OverrideMetadata(typeof(Infragistics.Windows.OutlookBar.OutlookBarGroup), new FrameworkPropertyMetadata(new PropertyChangedCallback

    (OnVisibilityChanged)));

    }

    // This PropertyChangedCallback will be called whenever the Visibility property of an OutlookBarGroup changes

     

     

    private static void OnVisibilityChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)

    {

    Infragistics.Windows.OutlookBar.

    OutlookBarGroup group = o as Infragistics.Windows.OutlookBar.OutlookBarGroup;

     

    if (group != null)

    {

     

    // If the value being set is Visibility.Collapsed and it is being set on the selected group,

     

    // select another group instead. (note that for simplicity in this code we are simply selecting the second group)

     

    if ((Visibility)e.NewValue == Visibility.Collapsed && group.IsSelected)

    {

     

    // Here we just select the second group, but you would add custom logic to

     

    // determine which other group should be selected.

    group.OutlookBar.Groups[1].IsSelected =

    true;

    }

    }

    }

    Joe