-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaced TabControl with TabControlEx #143
Conversation
LayoutDocumentPaneControl and LayoutAnchorablePaneControl were derived from regular WPF TabControl. I replaced it with TabControlEx which supports virtualization of tab controls to increase performance.
Making LayoutDocumentPaneControl and LayoutAnchorablePaneControl virtualized TabControls would be a cool contribution indeed :-) To make this configurable I suggest that we add:
#region IsVirtualizingLayoutDocument IsVirtualizingLayoutAnchorable
/// <summary>
/// Gets/sets (a simple non-dependency property) to determine whether the
/// <see cref="LayoutDocumentPaneControl"/> is virtualizing its child controls or not.
/// </summary>
public bool IsVirtualizingLayoutDocument { get; set; }
/// <summary>
/// Gets/sets (a simple non-dependency property) to determine whether the
/// <see cref="LayoutAnchorablePaneControl"/> is virtualizing its child controls or not.
/// </summary>
public bool IsVirtualizingLayoutAnchorable { get; set; }
#endregion IsVirtualizingLayoutDocument IsVirtualizingLayoutAnchorable at about line 1322 in the DockingManager.cs file. The default should be false (not virtualizing) so this is should be OK as is.
#region fields
private LayoutDocumentPane _model;
private bool _IsVirtualizing;
#endregion fields
#region Constructors
/// <summary>Static class constructor to register WPF style keys.</summary>
static LayoutDocumentPaneControl()
{
FocusableProperty.OverrideMetadata(typeof(LayoutDocumentPaneControl), new FrameworkPropertyMetadata(false));
}
/// <summary>Class constructor from model parameter.</summary>
/// <param name="model"></param>
/// <param name="IsVirtualizing"></param>
internal LayoutDocumentPaneControl(LayoutDocumentPane model, bool IsVirtualizing)
{
_IsVirtualizing = IsVirtualizing;
}
/// <summary>Class constructor from model parameter.</summary>
/// <param name="model"></param>
internal LayoutDocumentPaneControl(LayoutDocumentPane model)
{
_model = model ?? throw new ArgumentNullException(nameof(model));
SetBinding(ItemsSourceProperty, new Binding("Model.Children") { Source = this });
SetBinding(FlowDirectionProperty, new Binding("Model.Root.Manager.FlowDirection") { Source = this });
// Handle SizeChanged event instead of LayoutUpdated. It will exclude fluctuations of Actual size values.
// this.LayoutUpdated += new EventHandler( OnLayoutUpdated );
this.SizeChanged += OnSizeChanged;
}
#endregion Constructors #region fields
private LayoutAnchorablePane _model;
private bool _IsVirtualizing;
#endregion fields
#region Constructors
static LayoutAnchorablePaneControl()
{
FocusableProperty.OverrideMetadata(typeof(LayoutAnchorablePaneControl), new FrameworkPropertyMetadata(false));
}
/// <summary>Class constructor from model parameter.</summary>
/// <param name="model"></param>
/// <param name="IsVirtualizing"></param>
public LayoutAnchorablePaneControl(LayoutAnchorablePane model, bool IsVirtualizing)
: this(model)
{
_IsVirtualizing = IsVirtualizing;
}
/// <summary>Class constructor from model parameter.</summary>
/// <param name="model"></param>
public LayoutAnchorablePaneControl(LayoutAnchorablePane model)
{
_model = model ?? throw new ArgumentNullException(nameof(model));
SetBinding(ItemsSourceProperty, new Binding("Model.Children") { Source = this });
SetBinding(FlowDirectionProperty, new Binding("Model.Root.Manager.FlowDirection") { Source = this });
// Handle SizeChanged event instead of LayoutUpdated. It will exclude fluctuations of Actual size values.
// this.LayoutUpdated += new EventHandler( OnLayoutUpdated );
SizeChanged += OnSizeChanged;
}
#endregion Constructors
For the LayoutDocumentPaneControl adjust the constructor statement in DockingManager:
For the LayoutAnchorablePaneControl adjust the constructor statement in DockingManager:
This implementation would allow a client application to set this configuration at start-up time and I'd like to make it a non-binding property so people do not expect to be able to change this at run-time: <avalonDock:DockingManager
x:Name="dockManager"
IsVirtualizingLayoutAnchorable="True"
IsVirtualizingLayoutDocument="True"
...
</avalonDock:DockingManager SummaryWhat I am not sure about is how to add this configuration setting into the TabControlEx such that it can be used in a virtualizing and non-virtualizing mode. But I understand its possible? Would you please re-order the methods in TabControlEx by their accessibility (public, override, protected, private) and use regions (fields, constructors, properties, methods) and add comments for all non-private items as we now established in the rest of the code? I think you would just have to make these changes in your fork, test them, and if you are happy with your test, commit it into your fork. The PR should then update to list the additional commit(s) and tracking this change in Dirkster/AvalonDock master would be much easier because the feature addition/change is visible in one place :-) What do you think about this solution? Would this work for you and for others since the defaults remain the same? |
I think this would work (other docking solutions do this, the original xceed dock does it (see the issue and release note). As for your question, I'm not sure either but I guess I can modify |
Hi @matko238 I was just wondering if you are going to complete the above changes. If not could you please let me know:
Thanx Drk |
Hi, But if you want you can finish it - to disable virtualization I guess it will be enough to skip |
OK, I merged and added it as described - I am glad we made this optional because I already see an issue #148 with LayoutAnchoreables when virtualization is turned ON. I have not looked into it but it seems like the number of items is not reported correctly (it seems to think the count is 1) when virtualization is turned on(?) |
LayoutDocumentPaneControl and LayoutAnchorablePaneControl were derived from regular WPF TabControl. I replaced it with TabControlEx which supports virtualization of tab controls to increase performance. See issue #142 for more details.
TODO: Someone may not like this behavior. An option should be added at
DockingManager
level or as a property ofLayoutAnchorable
so it retains original behavior (documents are unloaded/loaded when "tabs"/documents are changed.