Reputation: 83
I am creating a DockingManager with avalonDock in my xaml file and i can't figure out a way to align the tabs it creats on the top right. They are always on the top left side.
like this :
I have seen : How to set AvalonDock DockablePane to right in WPF but I could not find "ResizingPanel" under "DockingManager"
Does anyone knows how to do it ?
here is a sample of my xaml :
<Grid>
<avalonDock:DockingManager x:Name="dockingManager" Margin="0,10,0,-10"
DocumentsSource="{Binding Files}"
Grid.Row="0" >
<avalonDock:DockingManager.LayoutItemTemplateSelector>
<panel:PanelTemplateSelector>
<panel:PanelTemplateSelector.FileViewTemplate>
<DataTemplate>
<view:Shooting/>
</DataTemplate>
</panel:PanelTemplateSelector.FileViewTemplate>
</panel:PanelTemplateSelector>
</avalonDock:DockingManager.LayoutItemTemplateSelector>
<avalonDock:DockingManager.LayoutItemContainerStyleSelector>
<panel:PanelStyleSelector>
<panel:PanelStyleSelector.StartPageStyle>
<Style TargetType="{x:Type avalonControl:LayoutItem}">
<Setter Property="Title" Value="{Binding Model.Title}"/>
<Setter Property="ToolTip" Value="{Binding Model.StartPageTip}"/>
<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}"/>
<Setter Property="IconSource" Value="{Binding Model.IconSource}"/>
<Setter Property="ContentId" Value="{Binding Model.ContentId}"/>
<Setter Property="CanClose" Value="False"></Setter>
</Style>
</panel:PanelStyleSelector.StartPageStyle>
</panel:PanelStyleSelector>
</avalonDock:DockingManager.LayoutItemContainerStyleSelector>
<avalonDock:DockingManager.LayoutUpdateStrategy>
<panel:LayoutInitializer/>
</avalonDock:DockingManager.LayoutUpdateStrategy>
</avalonDock:DockingManager>
Upvotes: 2
Views: 1208
Reputation: 452
TabItems are hosted in a DocumentPaneTabPanel which its FlowDirection property has been set to LeftToRight in constructor,
i recommend do the following:
Copy the following in the form where the DockingManager is located:
private void DockingManager_LayoutUpdated(object sender, EventArgs e)
{
var q = FindVisualChild<Xceed.Wpf.AvalonDock.Controls.DocumentPaneTabPanel>(dockingManager);
if (q != null)
{
q.FlowDirection = FlowDirection.RightToLeft;
dockingManager.LayoutUpdated -= DockingManager_LayoutUpdated;
}
}
public T FindVisualChild<T>(DependencyObject obj) where T : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
if (child != null && child is T)
return (T)child;
else
{
T childOfChild = FindVisualChild<T>(child);
if (childOfChild != null)
return childOfChild;
}
}
return null;
}
Copy the following in the form's Constructor after InitializeComponent:
dockingManager.LayoutUpdated += DockingManager_LayoutUpdated;
Now , my CodeBehind looks like this:
public MainWindow()
{
InitializeComponent();
dockingManager.LayoutUpdated += DockingManager_LayoutUpdated;
}
private void DockingManager_LayoutUpdated(object sender, EventArgs e)
{
var q = FindVisualChild<Xceed.Wpf.AvalonDock.Controls.DocumentPaneTabPanel>(dockingManager);
if (q != null)
{
q.FlowDirection = FlowDirection.RightToLeft;
dockingManager.LayoutUpdated -= DockingManager_LayoutUpdated;
}
}
public T FindVisualChild<T>(DependencyObject obj) where T : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
if (child != null && child is T)
return (T)child;
else
{
T childOfChild = FindVisualChild<T>(child);
if (childOfChild != null)
return childOfChild;
}
}
return null;
}
Upvotes: 2