【问题标题】:TreeView and ViewModel树视图和视图模型
【发布时间】:2012-01-18 22:05:47
【问题描述】:

任何人都可以告诉我,对于这种情况,我该如何实现 ObjectBaseViewModel 和 ViewModel ?

WPF TreeView: How to style selected items with rounded corners like in Explorer,

我只是想消除 TreeView 的角落,但我从未使用过 ViewModel 模式。

提前谢谢...

【问题讨论】:

    标签: wpf treeview viewmodel


    【解决方案1】:

    看起来他的示例已经使用了一个视图模型,特别是在此片段中绑定到 HierarchicalDataTemplate:

        <HierarchicalDataTemplate DataType="{x:Type viewmodels:ObjectBaseViewModel}" ItemsSource="{Binding Children}">
            <StackPanel Orientation="Horizontal" Margin="2,1,5,2">
                <Grid Margin="0,0,3,0">
                    <Image Name="icon" Source="/ExplorerTreeView/Images/folder.png"/>
                </Grid>
                <TextBlock Text="{Binding Name}" />
            </StackPanel>
        </HierarchicalDataTemplate>
    

    您只需将 ViewModel 绑定到 ItemsSource,就像他对“Children”所做的那样。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-07
      • 2011-06-06
      • 1970-01-01
      • 2010-12-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多