Hello,
Is there a way to hide or disable the Navigation Splitter in the the WinExplorerBar control when the Style property is set to Office2007?
I was looking on the archived forums and there was a post a couple years back where someone stated that this is not possible - unless you use a CreationFilter.
Is this the case for the v7.3 as well? If so, can someone provide a sample of creating a CreationFilter to accomplish this?
Thanks in advance!
You could remove the element using a creation filter, but the caviat there is that the space it occupies will be unavailable to you, and the contorl's background will show in that area.
The following code sample demonstrates how to use the IUIElementCreationFilter interface to replace the existing element with one that looks and behaves as if it were disabled (assign an instance of this class to the control's CreationFilter property):
#region DisabledNavigationBarSplitterCreationFilter/// <summary>/// IUIElementCreationFilter implementation which disables the splitter bar/// for the OutlookNavigationPane style ExplorerBar./// </summary>public class DisabledNavigationBarSplitterCreationFilter : IUIElementCreationFilter{ #region Member variables private DisabledNavigationSplitterBarUIElement recycledSplitterBarElement = null; private Color disabledColor = Color.Empty; #endregion Member variables
#region Constructor /// <summary> /// Creates a new instance of the class. /// </summary> public DisabledNavigationBarSplitterCreationFilter( Color disabledColor ) { this.disabledColor = disabledColor; } #endregion Constructor
#region IUIElementCreationFilter implementation
void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { GroupAreaUIElement groupAreaElement = parent as GroupAreaUIElement;
if ( groupAreaElement != null ) { // Get the default NavigationSplitterBarUIElement and remove it UIElementsCollection childElements = groupAreaElement.ChildElements;
NavigationSplitterBarUIElement defaultSplitterElement = groupAreaElement.GetDescendant( typeof(NavigationSplitterBarUIElement) ) as NavigationSplitterBarUIElement;
if ( defaultSplitterElement != null ) { Rectangle rect = defaultSplitterElement.Rect;
childElements.Remove( defaultSplitterElement );
// Set the bounds of the DisabledNavigationSplitterBarUIElement // to the same bounds as the defualt element, and add it. if ( this.recycledSplitterBarElement == null ) this.recycledSplitterBarElement = new DisabledNavigationSplitterBarUIElement( groupAreaElement, this.disabledColor );
this.recycledSplitterBarElement.Rect = rect;
childElements.Add( this.recycledSplitterBarElement ); }
} }
bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { // Grab the existing DisabledNavigationSplitterBarUIElement, if there is one, // so we can reduce object instantiation overhead by reusing an existing instance. GroupAreaUIElement groupAreaElement = parent as GroupAreaUIElement;
if ( groupAreaElement != null ) this.recycledSplitterBarElement = groupAreaElement.GetDescendant( typeof(DisabledNavigationSplitterBarUIElement) ) as DisabledNavigationSplitterBarUIElement;
return false; }
#endregion IUIElementCreationFilter implementation
#region DisabledNavigationSplitterBarUIElement /// <summary> /// NavigationSplitterBarUIElement-derived element with a disabled appearance, /// and which cannot be dragged. /// </summary> public class DisabledNavigationSplitterBarUIElement : NavigationSplitterBarUIElement { private Color disabledColor = Color.Empty;
/// <summary> /// Creates a new instance of the class. /// </summary> public DisabledNavigationSplitterBarUIElement( UIElement parent, Color disabledColor ) : base( parent ) { this.disabledColor = disabledColor; }
/// <summary> /// Overridden to do nothing, which effectively disables the element. /// </summary> protected override void OnMouseMove(MouseEventArgs e){}
/// <summary> /// Overridden to make the element appear disabled /// </summary> protected override void InitAppearance(ref AppearanceData appearance, ref AppearancePropFlags requestedProps) { base.InitAppearance(ref appearance, ref requestedProps);
Color disabledColor = this.disabledColor.IsEmpty == false ? this.disabledColor : Color.Gray;
appearance.BackColor = disabledColor; appearance.BackColor2 = disabledColor; }
/// <summary> /// Returns null so that the 'SizeNS' cursor is not shown. /// </summary> public override Cursor Cursor { get { return null; } }
} #endregion DisabledNavigationSplitterBarUIElement}#endregion DisabledNavigationBarSplitterCreationFilter
Hi,
I have implemented what you have suggested above, but the solution is quite unsatisfactory to me. Is it possible to just completely disable the splitter and more importantly the overflow indicator?
Sincerely yours,
Paul van Iterson
In your original post, you mentioned nothing about the overflow indicator, only the splitter. In fact, you specifically asked for "a sample of creating a CreationFilter to accomplish this". The solution I posted does exactly that.
If you like you can visit http://devcenter.infragistics.com/Protected/RequestFeature.aspx and submit a request for the feature(s) you would like to see implemented in the control.
I agree - I did not use the suggestion given above as it is just a hack to get around the fact the ExplorerBar does not have a Property to 'hide the Overflow area' OR a 'LockSplitter' property to prevent the splitter from being moved.