0

有人能告诉我为什么紫色路径与第二条路径的比例不同吗?它们在切换按钮的控制模板中设置,如下所示。此外,您可以在此处查看结果:

http://picpaste.com/weird_path-nxRoeKjb.jpg

           <Grid x:Name="ToggleButtonGrid"
              Background="Navy"
            >
              <Path x:Name="ExpandPath"
              HorizontalAlignment="Center"
              VerticalAlignment="Center"
              Stretch="Fill"
              Fill="Gray"
              Stroke="Purple"
              Data="M 0 0 L 12 0 L 12 12 L 0 12 Z" />
              <Path
              HorizontalAlignment="Center" 
              VerticalAlignment="Center"
              Fill="Gray"
              Stretch="Fill"
              Stroke="Yellow"
              Data="M 0 6 L 12 6 Z" />
            </Grid>

然后在树视图的控件模板中设置。我不明白为什么要调整大小。它们都只是包含在一个网格中。我希望网格可以调整大小,但我得到了这个

<ControlTemplate TargetType="{x:Type TreeViewItem}">
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition x:Name="TreeViewExpanderColumn" MinWidth="19"
              Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition/>
      </Grid.RowDefinitions>
      <ToggleButton x:Name="Expander"
          Style="{StaticResource ExpandCollapseToggleStyle}"
          IsChecked="{Binding Path=IsExpanded,
                      RelativeSource={RelativeSource TemplatedParent}}"
          ClickMode="Press"/>
      <Border Name="Bd"
      Grid.Column="1"
      Background="{TemplateBinding Background}"
      BorderBrush="{TemplateBinding BorderBrush}"
      BorderThickness="0"
      Padding="0">
        <ContentPresenter x:Name="PART_Header"
              ContentSource="Header"
              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
      </Border>
      <ItemsPresenter 
        x:Name="ItemsHost" 
        Margin="-19,0,0,0"
        Grid.Row="1"
        Grid.Column="1"
        Grid.ColumnSpan="2"/>
4

1 回答 1

0

使用路径画线和一些缩放是一个问题。不知道发生了什么,但使用 Line 来修复它。

            <Path 
              HorizontalAlignment="Center"
              VerticalAlignment="Center"
              Stretch="Fill"
              Fill="Gray"
              Stroke="White"
              Data="M 0 0 L 12 0 L 12 12 L 0 12 Z" />
              <Line 
              HorizontalAlignment="Center" 
              VerticalAlignment="Center"
              Fill="Gray"
               X1="0"
               Y1="0"
               X2="12"
               Y2="0"
              Stroke="White"
              />
              <Line x:Name="VerticalCrossBar"
              HorizontalAlignment="Center" 
              VerticalAlignment="Center"
              Fill="Gray"
               X1="0"
               Y1="0"
               X2="0"
               Y2="12"
              Stroke="White"
              />
于 2013-07-01T19:26:31.470 回答