Home Forums WPF controls Other WPF controls Avalon Dock: Data bound title works in designer, but not when running app

Mots-clés : 

4 sujets de 1 à 4 (sur un total de 4)
  • Auteur
  • rabjen-iwes
    Post count: 8
    #44491 |

    I am currently trying to create a UI using Avalon Dock from Xceed WPF Toolkit 3. I created a much simpler version of this example. Basically, my view model looks like this:

    namespace NonWorkingAvalonDock {
        public sealed class MainViewModel {
            public MainViewModel() {
                Pages = new SimplePageViewModel[] {
                    new SimplePageViewModel("Foo"),
                    new SimplePageViewModel("Bar")
            public SimplePageViewModel[] Pages { get; }
        public sealed class SimplePageViewModel {
            public SimplePageViewModel(string title) {
                Title = title;
            public string Title { get; }

    And my XAML looks like this:

    <Window x:Class="NonWorkingAvalonDock.MainWindow"
            Title="MainWindow" Height="350" Width="525">
            <local:MainViewModel x:Key="ViewModel" />
        <dock:DockingManager DataContext="{StaticResource ViewModel}" AnchorablesSource="{Binding Pages}" >
                <!-- you can add additional bindings from the layoutitem to the DockWindowViewModel -->
                <Style TargetType="{x:Type dockctrl:LayoutItem}" >
                    <Setter Property="Title" Value="{Binding Model.Title}" />

    When I look at the result in the Designer, It looks alright:

    But when I run my application, the headers and titles are missing:

    What is going wrong here?

    Post count: 8


    I investigated the example and my code a bit more, and in the example, the author sets the data context in code behind. When I do this, it works for me, too.

    Moreover, I did the following experiment: I made the Pages property privately writable, initialized it with null and used a Timer which sets the view models after one second. When I do this, I get the titles, too.

    Is this a bug or do I have to do some additional stuff to make the binding appear without codebehind?

    Fawzi [Xceed]
    Post count: 722


    This will be fixed in v3.3.

    In the meantime, you can go in file Xceed.Wpf.AvalonDock/DockingManager.cs,
    in method « CreateAnchorableLayoutItem »,
    Replace :

    if (_layoutItems.Any(item => item.LayoutElement == contentToAttach))

    with :

    if( _layoutItems.Any( item => item.LayoutElement == contentToAttach ) )
    foreach( var item in _layoutItems )
    ApplyStyleToLayoutItem( item );

    Diane [Xceed]
    Post count: 1353

    Toolkit v3.3 is now available, and includes the following fix:

    In AvalonDock, using a style selector (property DockingManager.LayoutItemContainerStyleSelector) with the DockingManager.DocumentsSource property will now apply the desired style.

    Download Link: http://forums.xceed.com/latest-xceed-toolkit-plus-for-wpf

4 sujets de 1 à 4 (sur un total de 4)
  • Vous devez être connecté pour répondre à ce sujet.