1

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

1 に答える 1

0

Caliburn Microを見始めたところです。ただし、MVVM パターンで DevExpress ナビゲーション バーを使用する方法について調査しました。開発チームに例を尋ねました。彼らは、コントロールにバグがあり、それが機能しないと言いました。彼らは回避策の例を示しました。リンクはこちら: http://www.devexpress.com/Support/Center/p/Q347737.aspx

私は彼らのソリューションを見ましたが、複雑すぎて使用できませんでした。パッチがすぐに利用可能になることを願っています。

キース

更新 リンクが機能しないことに気づきませんでした。ソリューションのより詳細な説明は次のとおりです。

  1. ナビゲーション バーのユーザー コントロールが作成されます。

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

2 つのターゲット タイプは、*wrapper と呼ばれる 2 つのクラスです。彼らは次のようなバインディングを行います: BindingOperations.SetBinding(NavBarGroup, NavBarGroup.ContentProperty, new Binding("Content") { Source = this });

これは NavBarGroup というクラスを参照していることに注意してください。4 つのヘルパー グループがあります。NavBarGroup、NavBarItems、NavBarGroups(NavBarGroup のリスト)、および NavBarItems(NavBarItem のリスト) これらのクラスは、データを静的メンバーとして保持する別の 4 つの同等のクラスによって設定されます。私にとって契約を破ったのは、これらの最後のクラスです。一線を越えて複雑すぎるようです。それが役立つことを願っています。キース

于 2011-10-26T16:39:30.537 に答える