Caliburn 与 DevExpress NavBarControl 配合不佳

发布于 2024-10-19 01:16:30 字数 781 浏览 1 评论 0原文

有没有人有过使用 Caliburn 和 DevExpress NavBarControl 的经验。我正在尝试将 NavBarItems 列表绑定到我的视图模型。这不起作用,我确定这是因为 Caliburn 的绑定。

例如

<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; }
}

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; }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月依秋水 2024-10-26 01:16:30

我刚刚开始关注 Caliburn Micro。不过,我对使用 DevExpress 导航栏和 MVVM 模式进行了一些研究。我向开发团队询问了一个例子。他们说他们的控制中存在一个错误,导致其无法工作。他们确实给出了一个解决方法的例子。链接在这里:
http://www.devexpress.com/Support/Center/p/Q347737.aspx

我查看了他们的解决方案,它对我来说太复杂了,无法使用。希望补丁很快就能推出。

基思

更新
我没有意识到该链接不起作用。以下是该解决方案的更详细说明:

  1. 为导航栏创建用户控件:

    
    <网格>
        
            
                >
            
            
                
                    
                        
    

这两个 Target 类型是两个名为 *wrapper 的类。他们进行绑定,如下所示:
BindingOperations.SetBinding(NavBarGroup, NavBarGroup.ContentProperty, new Binding("Content") { Source = this });

请注意,这引用了一个名为 NavBarGroup 的类。有四个帮助小组。 NavBarGroup、NavBarItems、NavBarGroups(NavBarGroup 列表)和 NavBarItems(NavBarItem 列表)
这些类由另外四个等效类填充,它们将数据作为静态成员保存。正是最后这些课程对我来说是破坏性的。它似乎越界过于复杂。
希望有帮助。
基思

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文