Question

Has anyone had any experiences with Caliburn and the DevExpress NavBarControl. I am attempting to bind the list of NavBarItems to my View Model. This doesn't work and i'm sure it's because of Caliburn's bindings.

e.g.

<dxnb:NavBarControl x:Name="NavigationBar">
    <dxnb:NavBarControl.Groups>
        <dxnb:NavBarGroup x:Name="NavigationBarGroup" Content="{Binding PluginPresenter}" ImageSource="/Images/Icons/Group.png">
        </dxnb:NavBarGroup>
    </dxnb:NavBarControl.Groups>
    <dxnb:NavBarControl.View>
        <dxnb:NavigationPaneView IsExpandButtonVisible="False"/>
    </dxnb:NavBarControl.View>
</dxnb:NavBarControl>

public class ShellViewModel : PropertyChangeBase
{
   public NavBarItemCollection Plugins { get; set; }
   public NavBarGroup NavigationBarGroup { get; set; }
}
Was it helpful?

Solution

I just started to look at Caliburn Micro. However, I did some research on using the DevExpress Navigation bar with a MVVM pattern. I asked the development team for an example. They said there is a bug in their control that prevents it from working. They did give an example of a work around. Link is here: http://www.devexpress.com/Support/Center/p/Q347737.aspx

I looked at their solution and it was too complex for me to use. Hopefully the patch will be available soon.

Keith

UPDATE I didn't realize that the link didn't work. Here is a more detailed explanation of the solution:

  1. A user Control is created for the Navigation Bar:

    <UserControl x:Class="NavBarMVVM.View.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dxn="http://schemas.devexpress.com/winfx/2008/xaml/navbar"
    xmlns:ext="clr-namespace:NavBarExtensions;assembly=NavBarExtensions"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">
    <Grid>
        <dxn:NavBarControl x:Name="navBar">
            <dxn:NavBarControl.View>
                <dxn:NavigationPaneView/>
            </dxn:NavBarControl.View>
            <i:Interaction.Behaviors>
                <ext:NavBarMVVMAttachedBehavior ItemsSource="{Binding}">
                    <ext:NavBarMVVMAttachedBehavior.GroupStyle>
                        <Style TargetType="ext:NavBarGroupWrapper">
                            <Setter Property="Header" Value="{Binding Caption}"/>
                            <Setter Property="ItemsSource" Value="{Binding ItemsViewModel}"/>
                        </Style>
                    </ext:NavBarMVVMAttachedBehavior.GroupStyle>
                    <ext:NavBarMVVMAttachedBehavior.ItemStyle>
                        <Style TargetType="ext:NavBarItemWrapper">
                            <Setter Property="Content" Value="{Binding Name}"/>
                            <Setter Property="ImageSource" Value="{Binding PhotoImageSource}"/>
                            <Setter Property="Command" Value="{Binding ClickItemCommand}"/>
                        </Style>
                    </ext:NavBarMVVMAttachedBehavior.ItemStyle>
                </ext:NavBarMVVMAttachedBehavior>
            </i:Interaction.Behaviors>
    
        </dxn:NavBarControl>
    </Grid>
    

The two Target types are two classes called *wrapper. They do the binding like: BindingOperations.SetBinding(NavBarGroup, NavBarGroup.ContentProperty, new Binding("Content") { Source = this });

Notice that this reference a class called NavBarGroup. There are four helper groups. NavBarGroup, NavBarItems, NavBarGroups(List of NavBarGroup), and NavBarItems(LIst of NavBarItem) These classes are populated by another four equivalent classes which hold the data as static members. It is these last classes that were the deal breaker for me. It seem to cross the line to overly complex. Hope that helps. Keith

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top