WPF初学者。
我设法使用本文末尾显示的代码将TreeView控件绑定到DataViewManager。最初填充TreeView控件时一切正常,但我想实现双向绑定,以便我可以使用文本框过滤掉不需要的TreeView项。 我的问题是如果树形视图没有更新 我试图使用这样的东西:
private void SearchTree_TextChanged(object sender, TextChangedEventArgs e)
{
if(SearchTree.Text.Length>0)
Command.dvm.DataViewSettings["Categories"].RowFilter = "CategoryName LIKE '%"+SearchTree.Text+"%'";
}
任何人都可以帮助我找出我在这里做错了什么吗?!
的Xaml:
...
<UserControl.Resources>
<ObjectDataProvider
x:Key="dataVMProvider"
MethodName="CreateDataVM"
ObjectType="{x:Type local:DataVMCreator}"
/>
<DataTemplate x:Key="InstancesTemplate">
<TextBlock Text="{Binding InstanceUID}"/>
</DataTemplate>
<HierarchicalDataTemplate
x:Key="SymbolsTemplate"
ItemsSource="{Binding Symbols2Instances}"
ItemTemplate="{StaticResource InstancesTemplate}"
>
<TextBlock Text="{Binding SymbolName}"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate
x:Key="FamiliesTemplate"
ItemsSource="{Binding Families2Symbols}"
ItemTemplate="{StaticResource SymbolsTemplate}"
>
<TextBlock Text="{Binding FamilyName}"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate
x:Key="CategoriesTemplate"
ItemsSource="{Binding Categories2Families}"
ItemTemplate="{StaticResource FamiliesTemplate}"
>
<TextBlock Text="{Binding CategoryName}"/>
</HierarchicalDataTemplate>
</UserControl.Resources>
...
<TreeView
x:Name="ElementsTree"
...
DataContext="{StaticResource dataVMProvider}"
ItemsSource="{Binding Categories}"
ItemTemplate="{StaticResource CategoriesTemplate}"
/>
DataViewManager来自:
public static class DataVMCreator
{
public static DataViewManager CreateDataVM()
{
return Command.dvm;
}
}
答案 0 :(得分:0)
对function remove_my_metaboxes() {
remove_meta_box( 'categorydiv','post','normal' ); // Categories Metabox
remove_meta_box( 'submitdiv','post','normal' ); // Categories Metabox
remove_meta_box( 'postcustom','page','normal' ); // Custom Fields Metabox
remove_meta_box( 'postcustom','post','normal' ); // Custom Fields Metabox
remove_meta_box( 'commentstatusdiv','page','normal' ); // Comments Metabox
remove_meta_box( 'commentsdiv','post','normal' ); // Comments Metabox
remove_meta_box( 'trackbacksdiv','page','normal' ); // Talkback Metabox
remove_meta_box( 'trackbacksdiv','post','normal' ); // Trackback Metabox
remove_meta_box( 'authordiv','page','normal' ); // Author Metabox
remove_meta_box( 'authordiv','post','normal' ); // Author Metabox
remove_meta_box( 'postexcerpt','post','normal' ); // Excerpt Metabox
remove_meta_box( 'postexcerpt','page','normal' ); // Excerpt Metabox
remove_meta_box( 'revisionsdiv','post','normal' ); // Revisions Metabox
remove_meta_box( 'slugdiv','page','normal' ); // Slug Metabox
remove_meta_box( 'slugdiv','post','normal' ); // Slug Metabox
remove_meta_box( 'formatdiv','post','normal' ); // Formats Metabox
remove_meta_box( 'postimagediv','post','normal' ); // Featured Image Metabox
remove_meta_box( 'tagsdiv-post_tag','post','normal' ); // Tags Metabox
remove_meta_box( 'commentstatusdiv','post','normal' ); // Comments Status Metabox
}
add_action('admin_menu','remove_my_metaboxes');
的{{1}}:
DataContext