Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf Caliburn无法很好地使用DevExpress导航控件_Wpf_Devexpress_Caliburn - Fatal编程技术网

Wpf Caliburn无法很好地使用DevExpress导航控件

Wpf Caliburn无法很好地使用DevExpress导航控件,wpf,devexpress,caliburn,Wpf,Devexpress,Caliburn,有没有人有过Caliburn和DevXpress NavBarControl的经验。我正在尝试将NavBarItems列表绑定到我的视图模型。这不起作用,我相信这是因为Caliburn的绑定 e、 g 公共类ShellViewModel:PropertyChangeBase { 公共NavBarItemCollection插件{get;set;} 公共NavBarGroup导航BarGroup{get;set;} } 我刚开始看Caliburn Micro。然而,我做了一些关于使用DevExp

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

e、 g


公共类ShellViewModel:PropertyChangeBase
{
公共NavBarItemCollection插件{get;set;}
公共NavBarGroup导航BarGroup{get;set;}
}

我刚开始看Caliburn Micro。然而,我做了一些关于使用DevExpress导航栏和MVVM模式的研究。我请开发团队举个例子。他们说在他们的控制中有一个bug阻止它工作。他们确实给出了一个变通的例子。链接如下:

我看了看他们的解决方案,它太复杂了,我无法使用。希望这个补丁很快就可以使用

基思

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

  • 将为导航栏创建一个用户控件:

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

  • 这两种目标类型是两个名为*wrapper的类。它们的装订方式如下: BindingOperations.SetBinding(NavBarGroup,NavBarGroup.ContentProperty,新绑定(“内容”){Source=this})

    请注意,此引用包含一个名为NavBarGroup的类。有四个助手组。NavBarGroup、NavBarItems、NavBarGroup(NavBarGroup列表)和NavBarItems(NavBarItem列表) 这些类由另外四个等价的类填充,这些类将数据作为静态成员保存。正是这些最后的课程打破了我的交易。它似乎越线而变得过于复杂。 希望有帮助。
    Keith

    我不确定我是否看到了虚拟机和视图之间的关系。虚拟机上的属性应该是“PluginPresenter”而不是“Plugins”吗?此外,我们通常认为在VM中拥有控制特定代码是一种坏模式。我不太熟悉NavBarControl,你想要达到的最终结果是什么?我想要一个基于插件的系统(目录中的DLL)。DLL的名称将显示在一个列表中,供用户选择,该名称将用于加载DLL(插件)以及在视图上显示给用户的表单。您链接到的问题的解决方案无法公开查看。您能在此引用内容吗?MVVM导航栏的修复程序现在可从devexpress.com下载。版本11.9
    <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>