Caliburn Microを見始めたところです。ただし、MVVM パターンで DevExpress ナビゲーション バーを使用する方法について調査しました。開発チームに例を尋ねました。彼らは、コントロールにバグがあり、それが機能しないと言いました。彼らは回避策の例を示しました。リンクはこちら:
http://www.devexpress.com/Support/Center/p/Q347737.aspx
私は彼らのソリューションを見ましたが、複雑すぎて使用できませんでした。パッチがすぐに利用可能になることを願っています。
キース
更新
リンクが機能しないことに気づきませんでした。ソリューションのより詳細な説明は次のとおりです。
ナビゲーション バーのユーザー コントロールが作成されます。
<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 つの同等のクラスによって設定されます。私にとって契約を破ったのは、これらの最後のクラスです。一線を越えて複雑すぎるようです。それが役立つことを願っています。キース