0

我从这里下载示例代码 http://www.codeproject.com/Articles/28306/Working-with-Checkboxes-in-the-WPF-TreeView

示例代码工作正常。我的问题是我想把这部分 xaml 变成 C# 代码。

  <Window.Resources>
    <ResourceDictionary>
      <!-- Load this specific theme because the Aero theme for CheckBox has issues. -->


      <Style x:Key="TreeViewItemStyle" TargetType="TreeViewItem">
        <Setter Property="IsExpanded" Value="True" />
        <Setter Property="IsSelected" Value="{Binding IsInitiallySelected, Mode=OneTime}" />
        <Setter Property="KeyboardNavigation.AcceptsReturn" Value="True" />
        <Setter Property="dw:VirtualToggleButton.IsVirtualToggleButton" Value="True" />
        <Setter Property="dw:VirtualToggleButton.IsChecked" Value="{Binding IsChecked}" />        
      </Style>

      <HierarchicalDataTemplate 
        x:Key="CheckBoxItemTemplate"
        ItemsSource="{Binding Children, Mode=OneTime}"
        >
        <StackPanel Orientation="Horizontal">
          <!-- These elements are bound to a FooViewModel object. -->
          <CheckBox
            Focusable="False" 
            IsChecked="{Binding IsChecked}" 
            VerticalAlignment="Center"
            />
          <ContentPresenter 
            Content="{Binding Name, Mode=OneTime}" 
            Margin="2,0"
            />
        </StackPanel>
      </HierarchicalDataTemplate>
    </ResourceDictionary>
  </Window.Resources>

谁能告诉我该怎么做?谢谢,

4

0 回答 0