2017-03-25 10 views
0

私は開発中のMVVMアプリケーションでMultiSelectTreeViewコントロール(https://github.com/ygoe/MultiSelectTreeView)を使用しようとするかなり初心者のVisual Basic開発者です。それらを一緒に使用することに慣れるために、MultiSelectTreeViewデモをVBに翻訳し、Catelを使用してビューモデルの実装を開始しました。CatelはすべてのMultiSelectTreeViewプロパティを認識させるには?

私が見つけたのは、CatelがMultiSelectTreeViewのいくつかのプロパティを利用できないように見えるということです。 Catelを使用してテストを実行するには、デモウィンドウが開き、ほとんど期待通りに動作しますが、イミディエイトウィンドウは次のようにエラーの数を示しています

System.Windows.Data Warning: 40 : BindingExpression path error: '(Controls:MultiSelectTreeView.HoverHighlighting)' property not found on 'object' ''MultiSelectTreeView' (Name='TheTreeView')'. BindingExpression:Path=(Controls:MultiSelectTreeView.HoverHighlighting); DataItem='MultiSelectTreeView' (Name='TheTreeView'); target element is 'MultiSelectTreeViewItem' (Name=''); target property is 'HoverHighlighting' (type 'Boolean')

同様のメッセージがMultiSelectTreeView IsKeyboardModeとItemIndent性質のために存在しています。これらのプロパティをコードで設定するか、MainWindow XAMLで直接設定することは効果がなく、MultiSelectTreeViewのHoverHighlightingエフェクトはCatelを使用すると機能しなくなります。

テストプロジェクトをGitHub(https://github.com/AnotherKiwi/MultiSelectTreeViewDemoVB)にアップロードしました。マスターブランチにはMultiSelectTreeViewデモのVB変換が含まれており、すべての機能が動作します。 ImplementingMainWindowViewModelブランチで、私はCatelを使用してビューモデルを実装し始めました。上記のプロパティを含むものを除いて、デモのほとんどの機能が動作します。

CatelがこれらのMultiSelectTreeViewプロパティを妨害しているように見える理由について、誰かが指導を提供できれば、本当に感謝しています。私は与えられたアドバイスを適用しようとしている

<controls:MultiSelectTreeView 
      x:Name="TheTreeView" 
      ItemsSource="{Binding RootNode.Children}" 
      AllowEditItems="{Binding AllowEditItems}" 
      VerticalRulers="{Binding VerticalRulers}"> 

      <controls:MultiSelectTreeView.ContextMenu> 
       ... 
      </controls:MultiSelectTreeView.ContextMenu> 

      <i:Interaction.Triggers> 
       ... 
      </i:Interaction.Triggers> 

      <controls:MultiSelectTreeView.ItemContainerStyle> 
       <Style TargetType="{x:Type controls:MultiSelectTreeViewItem}"> 
        <Setter Property="DisplayName" Value="{Binding DisplayName}"/> 
        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/> 
        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/> 
        <Setter Property="IsEnabled" Value="{Binding IsEnabled, Mode=TwoWay}"/> 
        <Setter Property="IsVisible" Value="{Binding IsVisible, Mode=TwoWay}"/> 
        <Setter Property="IsEditable" Value="{Binding IsEditable, Mode=TwoWay}"/> 
        <Setter Property="IsEditing" Value="{Binding IsEditing, Mode=TwoWay}"/> 
        <Setter Property="Remarks" Value="{Binding Remarks}"/> 
        <Setter Property="IsKeyboardMode" Value="{Binding IsKeyboardMode, Mode=TwoWay}"/> 
        <Setter Property="HoverHighlighting" Value="{Binding HoverHighlighting}"/> 
        <Setter Property="ItemIndent" Value="{Binding ItemIndent}"/> 
        <Setter Property="ToolTip" Value="{Binding ToolTip}" /> 

        <Setter Property="ContentTemplateEdit"> 
         <Setter.Value> 
          <DataTemplate> 
           <StackPanel Orientation="Horizontal"> 
            <Border Background="YellowGreen" CornerRadius="3" Width="16" Height="16"/> 
            <controls:EditTextBox 
             Text="{Binding DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
             Padding="2,0,0,0"/> 
           </StackPanel> 
          </DataTemplate> 
         </Setter.Value> 
        </Setter> 
       </Style> 
      </controls:MultiSelectTreeView.ItemContainerStyle> 

      <controls:MultiSelectTreeView.Resources> 
       <!-- 
       Here the general item appearance is defined, for the ViewModel.TreeItemViewModel type 
       --> 
       <HierarchicalDataTemplate DataType="{x:Type vm:TreeItemViewModel}" ItemsSource="{Binding DataContext.Children}"> 
        <StackPanel Orientation="Horizontal"> 
         <Image Source="{Binding DataContext.ImageSource}" Width="16" Height="16" SnapsToDevicePixels="True"/> 
         <TextBlock Text="{Binding DataContext.DisplayName}" VerticalAlignment="Center" Padding="4,0,2,0"/> 
        </StackPanel> 
       </HierarchicalDataTemplate> 
      </controls:MultiSelectTreeView.Resources> 
     </controls:MultiSelectTreeView> 

MainWindow.xamlでMultiSelectTreeViewコントロールの宣言は以下のとおりである:@

は、いくつかの更なる情報は@Geertからの回答後に追加しましたGeertの答えですが、アプリケーションを実行すると、MultiSelectTreeViewは表示されません。私はWPFの新機能であり、おそらく適切なXAMLステートメントを変更していない可能性があります。これについてのより多くの助けは本当に感謝されるでしょう!

答えて

0

itemscontrol内の項目は新しいDataContext(項目)を取得するため、ItemTemplate内のVMに直接バインドすることはできません。

あなたがVMにバインドする必要がある場合は、このような何か行う必要があります。

<ItemsControl x:Name="myItemsControl" ItemsSource="{Binding MyItems}"> 
    <ItemsControl.ItemTemplate> 
    <DataTemplate> 
     <TextBlock Content="{Binding ElementName=myItemsControl, Path=DataContext.SomePropertyOnTheVm}" /> 
    </DataTemplate> 
    </ItemsControl.ItemTemplate> 
</ItemsControl> 
+0

を感謝@Geert ...あなたはので、(私は修正する必要がある私のXAMLの部分をピンポイントで助けてください可能性があり私はItemsControlを持っていません)?それはブロックしますか? –

+0

あなたのコメントを拡大しますか? –

関連する問題