123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <Window x:Class="WpfSample.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:WpfSample"
- xmlns:vm="clr-namespace:WpfSample.ViewModels"
- mc:Ignorable="d"
- Title="MainWindow" Height="450" Width="800"
- BorderThickness="0" Background="Coral">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="36"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <StackPanel Grid.Row="0" Orientation="Horizontal">
- <Button Command="{Binding AddItemCommand}" Content="Add"/>
- <TextBlock x:Name="tb1" local:PropADemo.Text="Hello World"/>
- <TextBlock x:Name="tb2" local:PropADemo.Text="Greeting"/>
- </StackPanel>
- <TreeView Grid.Row="1" ItemsSource="{Binding Groups}">
- <TreeView.Resources>
- <HierarchicalDataTemplate DataType="{x:Type vm:DemoGroupViewModel}" ItemsSource="{Binding Items}">
- <Border Background="Coral">
- <TextBlock Text="{Binding Message}"/>
- </Border>
- </HierarchicalDataTemplate>
- <HierarchicalDataTemplate DataType="{x:Type vm:DemoItemViewModel}">
- <Border Background="#669999">
- <TextBlock Text="{Binding Message}"/>
- </Border>
- </HierarchicalDataTemplate>
- </TreeView.Resources>
- <TreeView.ItemContainerStyle>
- <Style TargetType="TreeViewItem">
- <Setter Property="AllowDrop" Value="True"/>
- <EventSetter Event="MouseMove" Handler="TreeViewItem_MouseMove"/>
- <EventSetter Event="DragEnter" Handler="TreeViewItem_DragEnter"/>
- <EventSetter Event="DragOver" Handler="TreeViewItem_DragOver"/>
- <EventSetter Event="DragLeave" Handler="TreeViewItem_DragLeave"/>
- <EventSetter Event="Drop" Handler="TreeViewItem_Drop"/>
- </Style>
- </TreeView.ItemContainerStyle>
- </TreeView>
- </Grid>
- </Window>
|