Dragablz icon indicating copy to clipboard operation
Dragablz copied to clipboard

Expose an easier way to access Dragablz

Open RickStrahl opened this issue 7 years ago • 0 comments

Quite frequently when I need do some thing with the Tab control, I need access to the internals that are not exposed in the Tabablz control. There appears to be no clean way to get access to the underlying DragablzControl or the DragablzItem collections which incidentally are required for some of the public interfaces.

For example, I was trying to work around issue #211 by explicitly accessing the HeaderItemsOrganiser which has a Sort() method that takes a DragablzItem collection. In order to get to that I had to use Reflection to get at the private fields. Yuk :-)

// Original code that breaks due to null error per #211
//headers = TabControl.GetOrderedHeaders();
// Internal implementation of above
//return this._dragablzItemsControl.ItemsOrganiser.Sort(this._dragablzItemsControl.DragablzItems());

// Manually hacking access to this functionality
var control = ReflectionUtils.GetField(TabControl, "_dragablzItemsControl") as DragablzItemsControl;
var ditems = ReflectionUtils.CallMethod(control, "DragablzItems") as List<DragablzItem>;                    
headers = TabControl.HeaderItemsOrganiser?.Sort(ditems);

if (headers == null)
   // alternate behavior

Am I missing some other obvious ways to get at these properties? I'm wondering why these are internal especially since some of the public interfaces require them as parameters.

RickStrahl avatar Jul 08 '18 19:07 RickStrahl