GithubHelp home page GithubHelp logo

wieslawsoltes / dock Goto Github PK

View Code? Open in Web Editor NEW
802.0 21.0 90.0 309.94 MB

A docking layout system.

Home Page: https://wieslawsoltes.github.io/Dock/

License: MIT License

C# 98.78% PowerShell 0.66% Shell 0.51% Batchfile 0.05%
dock docking layout system avaloniaui avalonia control gui multi-platform xaml

dock's Introduction

Dock

Gitter

Build Status CI

NuGet NuGet MyGet

A docking layout system.

About

Dock is a docking layout system for Avalonia applications. Use of Dock is governed by the MIT License.

Dock

Building Dock

First, clone the repository or download the latest zip.

git clone https://github.com/wieslawsoltes/Dock.git

Build using .NET Core

Open up a terminal prompt and execute the commands.

Target framework netstandard2.0:

dotnet build src/Dock.Avalonia/Dock.Avalonia.csproj -c Release -f netstandard2.0

NuGet

Dock is delivered as a NuGet package.

You can find the packages here NuGet and install the package like this:

Install-Package Dock.Avalonia
Install-Package Dock.Model.Mvvm

or by using nightly build feed:

  • Add https://www.myget.org/F/dock-nightly/api/v2 to your package sources
  • Alternative nightly build feed https://pkgs.dev.azure.com/wieslawsoltes/GitHub/_packaging/Nightly/nuget/v3/index.json
  • Update your package using Dock feed

and install the package like this:

Install-Package Dock.Avalonia -Pre
Install-Package Dock.Model.Mvvm -Pre

Resources

License

Dock is licensed under the MIT license.

dock's People

Contributors

bandysc avatar dfkeenan avatar hendrikmennen avatar ivanjosipovic avatar lontivero avatar mbdev87 avatar miticcio avatar wieslawsoltes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dock's Issues

Add support for pinning views

Update: #164 brings new model for pinned dock, the pinned docks are supported only in IToolDock.

  • Implement object model
  • Implement dock factory logic
  • Implement UI presentation

Proposal for pinned views support in Dock control.

Model

  • Add IToolDock interface to controls to be used for pinned views in tool dock.
  • Add IsExpanded property to IToolDock.
  • Add AutoHide property to IToolDock.
  • Add implementation to INPC, ReactiveUI and Avalonia models.
  • When IDockable is pinned, remove it from visibible dockable collection and add to pinned dockables collection.

UI

  • Add TabStrip with PinnedDockables and pinned dockables detail view to ToolControl.
  • If the pin button for IDockable is clicked by user remove it from visibible dockable collection and add to pinned dockables collection..
  • If the user clicks on the TabStrip and AutoHide is set to True it reveals the tool overlaying the central UI and sets IsExpanded to true, if cursor is not over the view and AutoHide is set to true set IsExpanded to false.
  • When user clicks the pin button and AutoHide is set to true set the AutoHide to false and IsExpanded to true so the dock no more auto-hides views.

IDockFactory and IView don't exist

IDockFactory and IView don't exist when using the namespaces..
using Dock.Model;
using ReactiveUI;

    public class ViewModelMainWindow : ViewModelBase
    {
        private Dock.Model.IDockFactory _factory;
        private Dock.Model.IView _layout;
        private string _currentView;

        public IDockFactory Factory
        {
            get => _factory;
            set => this.RaiseAndSetIfChanged(ref _factory, value);
        }

        public IView Layout
        {
            get => _layout;
            set => this.RaiseAndSetIfChanged(ref _layout, value);
        }

        public string CurrentView
        {
            get => _currentView;
            set => this.RaiseAndSetIfChanged(ref _currentView, value);
        }
    }```

App freezes if you try to drag to PC desktop or other App

This is because it wants to binary serialize the data for another app to read in.

We need to either disable the option to drop outside the app (I don't know how or if its possible)

or support some kind of serialization, perhaps we can serialize the type name as utf8 encoded string?

Use styles in DockControl

<!-- Copyright (c) Wiesław Šoltés. All rights reserved. -->
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
<Styles xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:id="clr-namespace:Dock.Avalonia;assembly=Dock.Avalonia"
        xmlns:idc="clr-namespace:Dock.Avalonia.Controls;assembly=Dock.Avalonia"
        xmlns:converters="clr-namespace:Dock.Avalonia.Converters;assembly=Dock.Avalonia"
        xmlns:Dock="clr-namespace:Dock.Model;assembly=Dock.Model"
        xmlns:Controls="clr-namespace:Dock.Model.Controls;assembly=Dock.Model">
    <Style Selector="idc|DockControl">
        <Style.Resources>
            <converters:OrientationConverter x:Key="OrientationConverter"/>
            <converters:AlignmentConverter x:Key="AlignmentConverter"/>
        </Style.Resources>
        <Setter Property="Template">
            <ControlTemplate>
                <ContentControl Content="{TemplateBinding Layout}">
                    <ContentControl.DataTemplates>
                        <DataTemplate DataType="Controls:ISplitterDock">
                            <idc:ProportionalStackPanelSplitter>
                                <idc:ProportionalStackPanelSplitter.Styles>
                                    <Style Selector="idc|ProportionalStackPanelSplitter">
                                        <Setter Property="Background" Value="Transparent"/>
                                    </Style>
                                </idc:ProportionalStackPanelSplitter.Styles>
                            </idc:ProportionalStackPanelSplitter>
                        </DataTemplate>
                        <DataTemplate DataType="Controls:IDocumentDock">
                            <idc:DocumentControl>
                                <idc:DocumentControl.Styles>
                                    <Style Selector="idc|DocumentControl">
                                        <Setter Property="idc:ProportionalStackPanelSplitter.Proportion" Value="{Binding Proportion}"/>
                                    </Style>
                                </idc:DocumentControl.Styles>
                            </idc:DocumentControl>
                        </DataTemplate>
                        <DataTemplate DataType="Controls:IToolDock">
                            <idc:DockToolChrome IsActive="{Binding IsActive}">
                                <idc:DockToolChrome.Styles>
                                    <Style Selector="idc|DockToolChrome">
                                        <Setter Property="idc:ProportionalStackPanelSplitter.Proportion" Value="{Binding Proportion}"/>
                                    </Style>
                                </idc:DockToolChrome.Styles>
                                <idc:ToolControl/>
                            </idc:DockToolChrome>
                        </DataTemplate>
                        <DataTemplate DataType="Controls:IProportionalDock">
                            <ItemsControl Items="{Binding VisibleDockables}">
                                <ItemsControl.Styles>
                                    <Style Selector="ItemsControl">
                                        <Setter Property="idc:ProportionalStackPanelSplitter.Proportion" Value="{Binding Proportion}"/>
                                    </Style>
                                </ItemsControl.Styles>
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <idc:ProportionalStackPanel Name="DropProportional">
                                            <idc:ProportionalStackPanel.Styles>
                                                <Style Selector="idc|ProportionalStackPanel">
                                                    <Setter Property="id:DockProperties.IsDropArea" Value="True" />
                                                    <Setter Property="Background" Value="Transparent" />
                                                    <Setter Property="Orientation" Value="{Binding Orientation, Converter={StaticResource OrientationConverter}}" />
                                                </Style>
                                            </idc:ProportionalStackPanel.Styles>
                                        </idc:ProportionalStackPanel>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                        </DataTemplate>
                        <DataTemplate DataType="Controls:IPinDock">
                            <DockPanel Name="DropPin">
                                <DockPanel.Styles>
                                    <Style Selector="DockPanel">
                                        <Setter Property="id:DockProperties.IsDropArea" Value="True"/>
                                        <Setter Property="Background" Value="Transparent"/>
                                    </Style>
                                </DockPanel.Styles>
                                <TabStrip Items="{Binding VisibleDockables}" SelectedItem="{Binding AvtiveDockable, Mode=TwoWay}">
                                    <TabStrip.Styles>
                                        <Style Selector="TabStrip">
                                            <Setter Property="Focusable" Value="False" />
                                            <Setter Property="ClipToBounds" Value="False" />
                                            <Setter Property="DockPanel.Dock" Value="{Binding Alignment, Converter={StaticResource AlignmentConverter}}" />
                                        </Style>
                                        <Style Selector="TabStrip:empty">
                                            <Setter Property="IsVisible" Value="False" />
                                        </Style>
                                        <Style Selector="TabStrip /template/ ItemsPresenter#PART_ItemsPresenter > WrapPanel">
                                            <Setter Property="Orientation" Value="Vertical"/>
                                        </Style>
                                    </TabStrip.Styles>
                                    <TabStrip.DataTemplates>
                                        <DataTemplate DataType="Dock:IDockable">
                                            <StackPanel Name="DragPin">
                                                <StackPanel.Styles>
                                                    <Style Selector="StackPanel">
                                                        <Setter Property="id:DockProperties.IsDragArea" Value="True"/>
                                                        <Setter Property="id:DockProperties.IsDropArea" Value="True"/>
                                                        <Setter Property="Background" Value="Transparent"/>
                                                        <Setter Property="Orientation" Value="Horizontal"/>
                                                        <Setter Property="Spacing" Value="2"/>
                                                    </Style>
                                                </StackPanel.Styles>
                                                <TextBlock Text="{Binding Title}" Classes="drag" Margin="2" />
                                            </StackPanel>
                                        </DataTemplate>
                                    </TabStrip.DataTemplates>
                                </TabStrip>
                                <ContentControl Content="{Binding AvtiveDockable}" IsVisible="{Binding IsExpanded}"/>
                            </DockPanel>
                        </DataTemplate>
                        <DataTemplate DataType="Controls:IRootDock">
                            <DockPanel Name="DropRoot">
                                <DockPanel.Styles>
                                    <Style Selector="DockPanel">
                                        <Setter Property="id:DockProperties.IsDropArea" Value="True"/>
                                        <Setter Property="Background" Value="Transparent"/>
                                    </Style>
                                </DockPanel.Styles>
                                <ContentControl Content="{Binding Top}" DockPanel.Dock="Top"/>
                                <ContentControl Content="{Binding Bottom}" DockPanel.Dock="Bottom"/>
                                <ContentControl Content="{Binding Left}" DockPanel.Dock="Left"/>
                                <ContentControl Content="{Binding Right}" DockPanel.Dock="Right"/>
                                <Carousel Items="{Binding VisibleDockables}" SelectedItem="{Binding AvtiveDockable, Mode=TwoWay}" IsVirtualized="False"/>
                            </DockPanel>
                        </DataTemplate>
                    </ContentControl.DataTemplates>
                </ContentControl>
            </ControlTemplate>
        </Setter>
    </Style>
</Styles>

Drag layout

I may need your help. I have integrated the ribbon sample and the dock sample, but the dock can't drag the layout. I haven't checked out the problem. Can you help me?

Add build script

Create one PowerShell for all supported CI servers and local builds.

Tasks:

  • Build
  • Unit Tests
  • Publish Samples
  • Package NuGet
  • Publish MyGet
  • Publish NuGet

MainView

didn't understand the example. Can you explain why mainview is needed? I feel that there is one more layer of mainview than vs's dock. What's the difference between main and root?

Image size should match assets image size

The .png image width and height should match Image width and height defined in xaml to avoid blurry image resizing.

Drag from dock to new window with correct size

I try to give a new hostwindow automatically the size the original had.
I tried overriding the HostWindow and manually change the bounds but with no luck.
As you can see in the gif my window is also not drawn correctly as its contents are bigger than the window itself (Only happens on windows so most likely avalonia issue).

2019-10-2922-48-17

Build failed on linux

i tried to build the application by closing this repo
but got the following error:
Controls/DockToolChrome.cs(108,33): error CS0115: 'DockToolChrome.OnPropertyChanged(AvaloniaProperty, Optional, BindingValue, BindingPriority)': no suitable method found to override [/home/triophore/projects/tas/Dock/src/Dock.Avalonia/Dock.Avalonia.csproj]
4 Warning(s)
1 Error(s)

sdk version
.NET Core SDK (3.1.300)

IDE

Thanks for everything you did on github to improve Avalon Studio I will use it to create an IDE if I can help I will be very grateful since I am better at backend.

Crash when splitting window

Hello,
I really like your docking system and successfully integrated it in my program.
I noticed that it crashes when I try to split a tooltab when there is only one tool in the window.

2019-05-30

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Arg_ParamName_Name

Load default theme crash

I updated to your newest version to try the new fix.
I also use the latest Avalonia nightly now, since you named it 0.9.0 .
The default theme does not load for me since updating avalonia.

I load it like this:

<StyleInclude Source="avares://Dock.Avalonia.Themes.Default/DefaultTheme.xaml"/>

and I get this error while loading:

System.TypeLoadException: Could not load type 'Portable.Xaml.IRootObjectProvider' from assembly 'Avalonia.Markup.Xaml, Version=0.8.999.0, Culture=neutral, PublicKeyToken=null'.
   at Dock.Avalonia.Themes.Default.DefaultTheme.!XamlIlPopulate(IServiceProvider , DefaultTheme )
   at CompiledAvaloniaXaml.!XamlLoader.TryLoad(String )
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Uri uri, Uri baseUri) in D:\a\1\s\src\Markup\Avalonia.Markup.Xaml\AvaloniaXamlLoader.cs:line 58
   at Avalonia.Markup.Xaml.Styling.StyleInclude.get_Loaded() in D:\a\1\s\src\Markup\Avalonia.Markup.Xaml\Styling\StyleInclude.cs:line 54
   at Avalonia.Markup.Xaml.Styling.StyleInclude.Avalonia.Styling.ISetStyleParent.NotifyResourcesChanged(ResourcesChangedEventArgs e) in D:\a\1\s\src\Markup\Avalonia.Markup.Xaml\Styling\StyleInclude.cs:line 94
   at Avalonia.Styling.Styles.<.ctor>b__4_0(IStyle x) in D:\a\1\s\src\Avalonia.Styling\Styling\Styles.cs:line 36
   at Avalonia.Collections.AvaloniaListExtensions.<>c__DisplayClass1_0`1.<ForEachItem>g__Add|0(Int32 index, IList items) in D:\a\1\s\src\Avalonia.Base\Collections\AvaloniaListExtensions.cs:line 82
   at Avalonia.Collections.AvaloniaList`1.NotifyAdd(IList t, Int32 index) in D:\a\1\s\src\Avalonia.Base\Collections\AvaloniaList.cs:line 505
   at VHDPlus.App.!XamlIlPopulate(IServiceProvider , App ) in C:\Users\HendrikMennen\source\repos\VHDP\VHDPlus\App.xaml:line 54
   at VHDPlus.App.!XamlIlPopulateTrampoline(App )
   at VHDPlus.App.Initialize() in C:\Users\HendrikMennen\source\repos\VHDP\VHDPlus\App.xaml.cs:line 25
   at Avalonia.Controls.AppBuilderBase`1.Setup() in D:\a\1\s\src\Avalonia.Controls\AppBuilderBase.cs:line 273
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in D:\a\1\s\src\Avalonia.Controls\ApplicationLifetimes\ClassicDesktopStyleApplicationLifetime.cs:line 129
   at VHDPlus.Program.Main(String[] args) in C:\Users\HendrikMennen\source\repos\VHDP\VHDPlus\Program.cs:line 68

Do you know what could cause this? If I try without default theme it does not crash, but everything from the dock is invisible.

Example of nuget

image
Hi, can you give an example of nuget? I use it, but it's not normal. I can't reset it. There is no figure above

Especially if it is placed separately, the window can't be put back. I simulated the Notepad project.

Fix DockPanelSplitter invalid child items resizing

public class DockPanelSplitter : Thumb
{
private Control _element;
/// <summary>
/// Defines the <see cref="Thickness"/> property.
/// </summary>
public static readonly StyledProperty<double> ThicknessProperty =
AvaloniaProperty.Register<DockPanel, double>(nameof(Thickness), 4.0);
/// <summary>
/// Gets or sets the thickness (height or width, depending on orientation).
/// </summary>
/// <value>The thickness.</value>
public double Thickness
{
get { return GetValue(ThicknessProperty); }
set { SetValue(ThicknessProperty, value); }
}
/// <summary>
/// Initializes a new instance of the <see cref="DockPanelSplitter" /> class.
/// </summary>
public DockPanelSplitter()
{
}
/// <summary>
/// Gets a value indicating whether this splitter is horizontal.
/// </summary>
public bool IsHorizontal
{
get
{
var dock = GetDock(this);
return dock == Dock.Top || dock == Dock.Bottom;
}
}
protected override void OnDragDelta(VectorEventArgs e)
{
var dock = GetDock(this);
if (IsHorizontal)
{
AdjustHeight(e.Vector.Y, dock);
}
else
{
AdjustWidth(e.Vector.X, dock);
}
}
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
UpdateHeightOrWidth();
UpdateTargetElement();
}
private void AdjustHeight(double dy, Dock dock)
{
if (dock == Dock.Bottom)
{
dy = -dy;
}
SetTargetHeight(dy);
}
private void AdjustWidth(double dx, Dock dock)
{
if (dock == Dock.Right)
{
dx = -dx;
}
SetTargetWidth(dx);
}
private void SetTargetHeight(double dy)
{
double height = _element.DesiredSize.Height + dy;
if (height < _element.MinHeight)
{
height = _element.MinHeight;
}
if (height > _element.MaxHeight)
{
height = _element.MaxHeight;
}
var panel = GetPanel();
var dock = GetDock(this);
if (dock == Dock.Top && height > panel.DesiredSize.Height - Thickness)
{
height = panel.DesiredSize.Height - Thickness;
}
_element.Height = height;
}
private void SetTargetWidth(double dx)
{
double width = _element.DesiredSize.Width + dx;
if (width < _element.MinWidth)
{
width = _element.MinWidth;
}
if (width > _element.MaxWidth)
{
width = _element.MaxWidth;
}
var panel = GetPanel();
var dock = GetDock(this);
if (dock == Dock.Left && width > panel.DesiredSize.Width - Thickness)
{
width = panel.DesiredSize.Width - Thickness;
}
_element.Width = width;
}
private void UpdateHeightOrWidth()
{
if (IsHorizontal)
{
Height = Thickness;
Width = double.NaN;
Cursor = new Cursor(StandardCursorType.SizeNorthSouth);
PseudoClasses.Add(":horizontal");
}
else
{
Width = Thickness;
Height = double.NaN;
Cursor = new Cursor(StandardCursorType.SizeWestEast);
PseudoClasses.Add(":vertical");
}
}
private Dock GetDock(Control control)
{
if (this.Parent is ContentPresenter presenter)
{
return DockPanel.GetDock(presenter);
}
return DockPanel.GetDock(control);
}
private Panel GetPanel()
{
if (this.Parent is ContentPresenter presenter)
{
if (presenter.GetVisualParent() is Panel panel)
{
return panel;
}
}
else
{
if (this.Parent is Panel panel)
{
return panel;
}
}
return null;
}
private void UpdateTargetElement()
{
if (this.Parent is ContentPresenter presenter)
{
if (!(presenter.GetVisualParent() is Panel panel))
{
return;
}
int index = panel.Children.IndexOf(this.Parent);
if (index > 0 && panel.Children.Count > 0)
{
_element = (panel.Children[index - 1] as ContentPresenter).Child as Control;
}
}
else
{
if (!(this.Parent is Panel panel))
{
return;
}
int index = panel.Children.IndexOf(this);
if (index > 0 && panel.Children.Count > 0)
{
_element = panel.Children[index - 1] as Control;
}
}
}
}

Added tree drag and drop support for debug control

<TreeView x:Name="root" Grid.Column="0" Grid.Row="0">
<TreeViewItem Header="{Binding Title}" DataContext="{Binding}" Items="{Binding Views}">
<TreeViewItem.Styles>
<Style Selector="TreeViewItem">
<Setter Property="IsExpanded" Value="True"/>
</Style>
</TreeViewItem.Styles>
<TreeViewItem.DataTemplates>
<TreeDataTemplate DataType="Dock:IDock" ItemsSource="{Binding Views}">
<TextBlock Text="{Binding Title}" Classes="drag">
<i:Interaction.Behaviors>
<id:DragBehavior/>
</i:Interaction.Behaviors>
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem Header="_Split">
<MenuItem Header="Split to _Fill" Command="{Binding Factory.SplitToFill}" CommandParameter="{Binding}"/>
<Separator/>
<MenuItem Header="Split to _Left" Command="{Binding Factory.SplitToLeft}" CommandParameter="{Binding}"/>
<MenuItem Header="Split to _Right" Command="{Binding Factory.SplitToRight}" CommandParameter="{Binding}"/>
<Separator/>
<MenuItem Header="Split to _Top" Command="{Binding Factory.SplitToTop}" CommandParameter="{Binding}"/>
<MenuItem Header="Split to _Bottom" Command="{Binding Factory.SplitToBottom}" CommandParameter="{Binding}"/>
<Separator/>
<MenuItem Header="Split to _Window" Command="{Binding Factory.SplitToWindow}" CommandParameter="{Binding}"/>
</MenuItem>
<Separator/>
<MenuItem Header="_Add">
<MenuItem Header="Add _Layout" Command="{Binding Factory.AddLayout}" CommandParameter="{Binding}"/>
<MenuItem Header="Add _Root" Command="{Binding Factory.AddRoot}" CommandParameter="{Binding}"/>
<MenuItem Header="Add _Splitter" Command="{Binding Factory.AddSplitter}" CommandParameter="{Binding}"/>
<MenuItem Header="Add S_trip" Command="{Binding Factory.AddStrip}" CommandParameter="{Binding}"/>
<MenuItem Header="Add _View" Command="{Binding Factory.AddView}" CommandParameter="{Binding}"/>
</MenuItem>
<Separator/>
<MenuItem Header="Insert _Before">
<MenuItem Header="Insert _Layout Before" Command="{Binding Factory.InsertLayoutBefore}" CommandParameter="{Binding}"/>
<MenuItem Header="Insert _Root Before" Command="{Binding Factory.InsertRootBefore}" CommandParameter="{Binding}"/>
<MenuItem Header="Insert _Splitter Before" Command="{Binding Factory.InsertSplitterBefore}" CommandParameter="{Binding}"/>
<MenuItem Header="Insert S_trip Before" Command="{Binding Factory.InsertStripBefore}" CommandParameter="{Binding}"/>
<MenuItem Header="Insert _View Before" Command="{Binding Factory.InsertViewBefore}" CommandParameter="{Binding}"/>
</MenuItem>
<Separator/>
<MenuItem Header="Insert _After">
<MenuItem Header="Insert _Layout After" Command="{Binding Factory.InsertLayoutAfter}" CommandParameter="{Binding}"/>
<MenuItem Header="Insert _Root After" Command="{Binding Factory.InsertRootAfter}" CommandParameter="{Binding}"/>
<MenuItem Header="Insert _Splitter After" Command="{Binding Factory.InsertSplitterAfter}" CommandParameter="{Binding}"/>
<MenuItem Header="Insert S_trip After" Command="{Binding Factory.InsertStripAfter}" CommandParameter="{Binding}"/>
<MenuItem Header="Insert _View After" Command="{Binding Factory.InsertViewAfter}" CommandParameter="{Binding}"/>
</MenuItem>
<Separator/>
<MenuItem Header="_Convert">
<MenuItem Header="Convert to _Layout" Command="{Binding Factory.ConvertToLayout}" CommandParameter="{Binding}"/>
<MenuItem Header="Convert to _Root" Command="{Binding Factory.ConvertToRoot}" CommandParameter="{Binding}"/>
<MenuItem Header="Convert to _Splitter" Command="{Binding Factory.ConvertToSplitter}" CommandParameter="{Binding}"/>
<MenuItem Header="Convert to S_trip" Command="{Binding Factory.ConvertToStrip}" CommandParameter="{Binding}"/>
<MenuItem Header="Convert to _View" Command="{Binding Factory.ConvertToView}" CommandParameter="{Binding}"/>
</MenuItem>
<Separator/>
<MenuItem Header="_Remove" Command="{Binding Factory.Remove}" CommandParameter="{Binding}"/>
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
</TreeDataTemplate>
</TreeViewItem.DataTemplates>
</TreeViewItem>
</TreeView>

Binding to attached Proportion property does not work

When using custom namespace like xmlns:ac="clr-namespace:Avalonia.Controls;assembly=Dock.Avalonia" setting attached property in style setter result in exception.

<!-- FIXME: Binding to attached Proportion property does not work. -->
<!--<ItemsControl.Styles>
<Style Selector="ItemsControl > ContentPresenter">
<Setter Property="idc:ProportionalStackPanelSplitter.Proportion" Value="{Binding Proportion}"/>
</Style>
</ItemsControl.Styles>-->

<ItemsControl.Styles>
    <Style Selector="ItemsControl > ContentPresenter">
        <Setter Property="ac:ProportionalStackPanelSplitter.Proportion" Value="{Binding Proportion}"/>
    </Style>
</ItemsControl.Styles>
/// <summary>
/// Defines the Proportion attached property.
/// </summary>
public static readonly AttachedProperty<double> ProportionProperty =
    AvaloniaProperty.RegisterAttached<ProportionalStackPanelSplitter, IControl, double>("Proportion", double.NaN);

/// <summary>
/// Gets the value of the Proportion attached property on the specified control.
/// </summary>
/// <param name="control">The control.</param>
/// <returns>The Proportion attached property.</returns>
public static double GetProportion(IControl control)
{
    return control.GetValue(ProportionProperty);
}

/// <summary>
/// Sets the value of the Proportion attached property on the specified control.
/// </summary>
/// <param name="control">The control.</param>
/// <param name="value">The value of the Dock property.</param>
public static void SetProportion(IControl control, double value)
{
    control.SetValue(ProportionProperty, value);
}
Could not convert object 'ac:ProportionalStackPanelSplitter.Proportion' (of type System.String) to {clr-namespace:Avalonia;assembly=Avalonia.Base}AvaloniaProperty: Attached properties not supported.
   at Portable.Xaml.XamlObjectWriterInternal.GetCorrectlyTypedValue(XamlMember xm, XamlType xt, Object value) in C:\projects\Avalonia\src\Markup\Avalonia.Markup.Xaml\PortableXaml\portable.xaml.github\src\Portable.Xaml\Portable.Xaml\XamlObjectWriter.cs:line 694
   at Portable.Xaml.XamlObjectWriterInternal.StoreAppropriatelyTypedValue(ObjectState state, MemberAndValue ms, Object obj, Object keyObj) in C:\projects\Avalonia\src\Markup\Avalonia.Markup.Xaml\PortableXaml\portable.xaml.github\src\Portable.Xaml\Portable.Xaml\XamlObjectWriter.cs:line 620
   at Portable.Xaml.XamlObjectWriterInternal.OnWriteValue(Object value) in C:\projects\Avalonia\src\Markup\Avalonia.Markup.Xaml\PortableXaml\portable.xaml.github\src\Portable.Xaml\Portable.Xaml\XamlObjectWriter.cs:line 573
   at Portable.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter) in C:\projects\Avalonia\src\Markup\Avalonia.Markup.Xaml\PortableXaml\portable.xaml.github\src\Portable.Xaml\Portable.Xaml\XamlServices.cs:line 128
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.LoadFromReader(XamlReader reader, AvaloniaXamlContext context, IAmbientProvider parentAmbientProvider) in C:\projects\Avalonia\src\Markup\Avalonia.Markup.Xaml\AvaloniaXamlLoader.cs:line 208
   at Avalonia.Markup.Xaml.Templates.TemplateContent.Load() in C:\projects\Avalonia\src\Markup\Avalonia.Markup.Xaml\Templates\TemplateContent.cs:line 35
   at Avalonia.Controls.Presenters.ContentPresenter.CreateChild() in C:\projects\Avalonia\src\Avalonia.Controls\Presenters\ContentPresenter.cs:line 305
   at Avalonia.Controls.Presenters.ContentPresenter.UpdateChild() in C:\projects\Avalonia\src\Avalonia.Controls\Presenters\ContentPresenter.cs:line 222
   at Avalonia.Controls.Presenters.ContentPresenter.ContentChanged(AvaloniaPropertyChangedEventArgs e) in C:\projects\Avalonia\src\Avalonia.Controls\Presenters\ContentPresenter.cs:line 414
   at System.Reactive.Observer`1.OnNext(T value)
   at Avalonia.AvaloniaObject.RaisePropertyChanged(AvaloniaProperty property, Object oldValue, Object newValue, BindingPriority priority) in C:\projects\Avalonia\src\Avalonia.Base\AvaloniaObject.cs:line 527
   at Avalonia.AvaloniaObject.Avalonia.IPriorityValueOwner.Changed(AvaloniaProperty property, Int32 priority, Object oldValue, Object newValue) in C:\projects\Avalonia\src\Avalonia.Base\AvaloniaObject.cs:line 432
   at Avalonia.PriorityValue.<>c__DisplayClass27_0.<UpdateCore>b__0() in C:\projects\Avalonia\src\Avalonia.Base\PriorityValue.cs:line 284
   at Avalonia.Utilities.DeferredSetter`2.<>c__DisplayClass9_0`1.<SetAndNotify>b__0(Action notification) in C:\projects\Avalonia\src\Avalonia.Base\Utilities\DeferredSetter.cs:line 133
   at Avalonia.PriorityValue.UpdateCore(ValueTuple`2 update, ValueTuple`2& backing, Action`1 notify) in C:\projects\Avalonia\src\Avalonia.Base\PriorityValue.cs:line 284
   at Avalonia.Utilities.DeferredSetter`2.SetAndNotify[TValue](TProperty property, TValue& backing, SetterDelegate`1 setterCallback, TSetRecord value) in C:\projects\Avalonia\src\Avalonia.Base\Utilities\DeferredSetter.cs:line 129
   at Avalonia.PriorityValue.UpdateValue(Object value, Int32 priority) in C:\projects\Avalonia\src\Avalonia.Base\PriorityValue.cs:line 250
   at Avalonia.Data.TemplateBinding.Subscribed() in C:\projects\Avalonia\src\Markup\Avalonia.Markup\Data\TemplateBinding.cs:line 112
   at Avalonia.Reactive.SingleSubscriberObservableBase`1.Subscribe(IObserver`1 observer) in C:\projects\Avalonia\src\Avalonia.Base\Reactive\SingleSubscriberObservableBase.cs:line 36
   at Avalonia.PriorityBindingEntry.Start(IObservable`1 binding) in C:\projects\Avalonia\src\Avalonia.Base\PriorityBindingEntry.cs:line 83
   at Avalonia.PriorityLevel.Add(IObservable`1 binding) in C:\projects\Avalonia\src\Avalonia.Base\PriorityLevel.cs:line 114
   at Avalonia.ValueStore.AddBinding(AvaloniaProperty property, IObservable`1 source, BindingPriority priority) in C:\projects\Avalonia\src\Avalonia.Base\ValueStore.cs:line 42
   at Avalonia.AvaloniaObjectExtensions.Bind(IAvaloniaObject target, AvaloniaProperty property, IBinding binding, Object anchor) in C:\projects\Avalonia\src\Avalonia.Base\AvaloniaObjectExtensions.cs:line 170
   at Avalonia.Markup.Data.DelayedBinding.BindingEntry.Apply(IStyledElement control) in C:\projects\Avalonia\src\Markup\Avalonia.Markup\Markup\Data\DelayedBinding.cs:line 132
   at Avalonia.Markup.Data.DelayedBinding.ApplyBindings(IStyledElement control) in C:\projects\Avalonia\src\Markup\Avalonia.Markup\Markup\Data\DelayedBinding.cs:line 97
   at Avalonia.Markup.Data.DelayedBinding.ApplyBindings(Object sender, EventArgs e) in C:\projects\Avalonia\src\Markup\Avalonia.Markup\Markup\Data\DelayedBinding.cs:line 110
   at Avalonia.Visual.SetVisualParent(Visual value) in C:\projects\Avalonia\src\Avalonia.Visuals\Visual.cs:line 531
   at Avalonia.Visual.VisualChildrenChanged(Object sender, NotifyCollectionChangedEventArgs e) in C:\projects\Avalonia\src\Avalonia.Visuals\Visual.cs:line 544
   at Avalonia.Collections.AvaloniaList`1.NotifyAdd(IList t, Int32 index) in C:\projects\Avalonia\src\Avalonia.Base\Collections\AvaloniaList.cs:line 506
   at Avalonia.Controls.Primitives.TemplatedControl.ApplyTemplate() in C:\projects\Avalonia\src\Avalonia.Controls\Primitives\TemplatedControl.cs:line 268
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\projects\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 470
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\projects\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 318
   at Avalonia.Controls.Grid.MeasureOverride(Size constraint) in C:\projects\Avalonia\src\Avalonia.Controls\Grid.cs:line 214
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\projects\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 475
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\projects\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 318
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding) in C:\projects\Avalonia\src\Avalonia.Layout\LayoutHelper.cs:line 44
   at Avalonia.Controls.Presenters.ContentPresenter.MeasureOverride(Size availableSize) in C:\projects\Avalonia\src\Avalonia.Controls\Presenters\ContentPresenter.cs:line 325
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\projects\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 475
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\projects\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 318
   at Avalonia.Layout.Layoutable.MeasureOverride(Size availableSize) in C:\projects\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 524
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\projects\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 475
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\projects\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 318
   at Avalonia.Layout.LayoutManager.Measure(ILayoutable control) in C:\projects\Avalonia\src\Avalonia.Layout\LayoutManager.cs:line 173
   at Avalonia.Layout.LayoutManager.ExecuteMeasurePass() in C:\projects\Avalonia\src\Avalonia.Layout\LayoutManager.cs:line 124
   at Avalonia.Layout.LayoutManager.ExecuteLayoutPass() in C:\projects\Avalonia\src\Avalonia.Layout\LayoutManager.cs:line 89
   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) in C:\projects\Avalonia\src\Avalonia.Base\Threading\JobRunner.cs:line 70
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in C:\projects\Avalonia\src\Avalonia.Base\Threading\Dispatcher.cs:line 65
   at Avalonia.Application.Run(Window mainWindow) in C:\projects\Avalonia\src\Avalonia.Controls\Application.cs:line 236
   at AvaloniaDemo.Program.Main(String[] args) in C:\DOWNLOADS\GitHub\Dock\samples\AvaloniaDemo\Program.cs:line 46

Tabs that fall to the second line of the bar

Hi,

I'm working on a app to run cross database sql queries.

I noticed that when I have too many tabs open, the tabs that cannot fit the title bar are moved to the secend line, hidding other controls.
Is this a bug or I'm missing some settings ?

Thanks
Daniel

traficante good

traficante bad

Enable compiled bindings

Done.

Done.

Done.

<TextBlock DockPanel.Dock="Left" Text="{Binding ActiveDockable.Title}" HorizontalAlignment="Left" TextAlignment="Left" VerticalAlignment="Center" Height="25" Margin="0 8 8 0" Background="{Binding #Part_Grip.Background}" x:CompileBindings="False" />

<Button Classes="chromeButton" DockPanel.Dock="Right" Name="PART_CloseButton" Command="{Binding Owner.Factory.CloseDockable}" CommandParameter="{Binding ActiveDockable}" x:CompileBindings="False">

<Button Classes="chromeButton" DockPanel.Dock="Right" Command="{Binding Owner.Factory.PinDockable}" CommandParameter="{Binding ActiveDockable}" x:CompileBindings="False">

<TextBlock Text="*" IsVisible="{Binding IsDirty, FallbackValue=False}" x:CompileBindings="False"/>

<Button Height="14" Width="14" Command="{Binding Owner.Factory.CloseDockable}" CommandParameter="{Binding}" Classes="documentTabButton" x:CompileBindings="False">

<Grid Background="{DynamicResource ApplicationAccentBrushLow}" Height="2" DockPanel.Dock="Top" IsVisible="{Binding #PART_TabStrip.IsVisible}" x:CompileBindings="False" />

<Setter Property="Title" Value="{Binding ActiveDockable.Title}" x:CompileBindings="False"/>

<Button Content="Back" Command="{Binding GoBack}" IsEnabled="{Binding CanGoBack}" Grid.Column="0" x:CompileBindings="False"/>
<Button Content="Forward" Command="{Binding GoForward}" IsEnabled="{Binding CanGoForward}" Grid.Column="1" x:CompileBindings="False"/>
<Button Content="Home" Command="{Binding Navigate}" CommandParameter="{Binding DefaultDockable}" Grid.Column="2" x:CompileBindings="False"/>

<Button Content="Navigate" Command="{Binding Navigate}" CommandParameter="{Binding #Id.Text}" Grid.Column="4" x:CompileBindings="False"/>
<Button Content="ShowWindows" Command="{Binding ActiveDockable.ShowWindows}" Grid.Column="5" x:CompileBindings="False"/>
<Button Content="ExitWindows" Command="{Binding ActiveDockable.ExitWindows}" Grid.Column="6" x:CompileBindings="False"/>

Done.

Done.

Can this be used for Multiplatform development

Hi,
we will use Avalonia on a .NetCore 3.1 application to get our software running on multiplatforms.
Does this framework also work on mutliplatforms, like MacOS or Linux ?
Br
Markus

Pin Menu

Hi, has the pin menu in the dock panel been implemented anywhere? I'm not seeing it in the demos. Or do we need to use our own control template to set that up?
(thanks for this project, BTW)
--Andy

Code edit

How to add the interface of each area dynamically through the code?

Dragging from Window to Dock Control

Visual studio has 2 scenarios:

  1. User drags the titlebar to a dock control.
  • When this happens the mouse cursor is set to normal.
  • The chrome remains.
  • DockTargets are in popups with TopMost=True set.
  1. User drags a tab from a window to dock control.
  • Mouse cursor is set to normal.
  • The chrome and other parts of the window are hidden.
  • TopMost dock targets are shown.

SplitToWindow is not collapsing splitter

Collapsing the splitters does not work if a tool is dropped into a new window.
The resulting splitter that is left can crash the application if you accidently use it.

I tried to fix it myself but I was not sucessfull without messing up the entire code structure.
However the problem currently is that the line:
RemoveDockable(dockable, true); (Factorybase. line 723)
passes a tooldock that has children.
RemoveDockable calles Collapse() but that does not work if it has children.
if (dock.IsCollapsable && dock.VisibleDockables.Count == 0)

2019-09-1318-49-01 (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.