0

ServiceTreeコントロールに次のマークアップがありTreeView、サービスの を に表示する必要がありServiceGroupます。

<Grid>
    <TreeView ItemsSource="{Binding Services}" DataContext="{Binding}">
        <TreeView.ItemTemplate>
            <HierarchicalDataTemplate ItemsSource="{Binding Children}" DataType="{x:Type businessService:BusinessService}">
                <TreeViewItem Header="{Binding Name}"/>
            </HierarchicalDataTemplate>
        </TreeView.ItemTemplate>
    </TreeView>
</Grid>

最上位バインディングでServicesは、 に属するサービスのコレクションですServiceGroup

メイン ウィンドウで、次のデータ バインディングを使用してOdysseyプロジェクトOdcExpanderからを作成します。

<ItemsControl.ItemTemplate>
    <DataTemplate DataType="groups:ServiceGroup">
        <odc:OdcExpander Header="{Binding UIMetadata.MenuText}"  HeaderBackground="{Binding UIMetadata.MenuTabBackColor}">                            
            <XTime900Shell:ServiceTree />                            
        </odc:OdcExpander>
    </DataTemplate>
</ItemsControl.ItemTemplate>

これは機能します。それぞれに正しくバインドされた1つのエキスパンダーを取得ServiceGroupしますが、サービスを含むグループ、つまり「従業員」グループには、表示するサービスの数に高さが比例するツリービューが必要なスペースがあるため、バインドされていますコレクションプロパティ、Servicesおよび各サービスのアイテムを作成しますが、正しく入力されていることがわかっているサービスの「名前」プロパティには何も表示されません。

4

1 に答える 1

1

エラーは、TreeViewItem を使用していることだと思います。使用しないでください。データ テンプレートを作成している場合は、テキスト ブロックなどの任意のビジュアル アイテムを表示できます。ツリー ビュー アイテムはコンテナ アイテムになり、テキスト ボックスとして表示されます (例として)。あなたはこのようにする必要があります:

<TreeView.ItemTemplate>
        <HierarchicalDataTemplate ItemsSource="{Binding Children}" DataType="{x:Type businessService:BusinessService}">
            <TextBlock Text="{Binding Name}"/>
        </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>

うまくいくことを願っています...

于 2013-10-14T12:21:26.833 に答える