我正在使用telerik:RadTreeView
以下代码
<telerik:RadTreeView x:Name="ViewPlaybackTreeView" Uid="-1" IsTriStateMode="True" Style="{StaticResource SettingTreeViewStyle}"
ItemContainerStyle="{StaticResource SettingRadTreeViewTimePickerItemStyle}">
<telerik:RadTreeViewItem x:Name="ViewPlaybackTreeViewItem" Uid="-1" IsExpanded="False"
ItemContainerStyle="{StaticResource SettingRadTreeViewTimePickerItemStyle}"/>
</telerik:RadTreeView>
<Style x:Key="SettingTreeViewStyle" TargetType="telerik:RadTreeView">
<Setter Property="SelectionMode" Value="Extended"/>
<Setter Property="IsLineEnabled" Value="True"/>
<Setter Property="ItemsOptionListType" Value="CheckList"/>
<Setter Property="IsOptionElementsEnabled" Value="True"/>
<Setter Property="IsRootLinesEnabled" Value="True"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="IsTriStateMode" Value="True"/>
</Style>
<Style x:Key="SettingRadTreeViewTimePickerItemStyle" TargetType="{x:Type telerik:RadTreeViewItem}">
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Margin" Value="0,0,0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type telerik:RadTreeViewItem}">
<Grid x:Name="RootElement">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid x:Name="HeaderRow" Background="Transparent" MinHeight="{TemplateBinding MinHeight}" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="6" Grid.Column="2" CornerRadius="2"/>
<Border x:Name="SelectionUnfocusedVisual" BorderBrush="#FFDBDBDB" BorderThickness="1" Grid.ColumnSpan="6" Grid.Column="2" CornerRadius="1" Visibility="Collapsed">
<Border BorderBrush="Transparent" BorderThickness="1" CornerRadius="0">
<Border.Background>
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="#FFF8F6F9" Offset="0"/>
<GradientStop Color="#FFF0F0F0" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
</Border>
</Border>
<Border x:Name="SelectionVisual" BorderBrush="#FFFFC92B" BorderThickness="1" Grid.ColumnSpan="6" Grid.Column="2" CornerRadius="1" Visibility="Collapsed">
<Border BorderBrush="White" BorderThickness="1" CornerRadius="0">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFCE79F" Offset="1"/>
<GradientStop Color="#FFFDD3A8"/>
</LinearGradientBrush>
</Border.Background>
</Border>
</Border>
<StackPanel x:Name="IndentContainer" Orientation="Horizontal">
<Rectangle x:Name="IndentFirstVerticalLine" Stroke="#FFCCCCCC" Visibility="Collapsed" VerticalAlignment="Top" Width="1"/>
</StackPanel>
<Grid x:Name="ListRootContainer" Grid.Column="1" HorizontalAlignment="Center" MinWidth="20">
<Rectangle x:Name="HorizontalLine" HorizontalAlignment="Right" Height="1" Stroke="#FFCCCCCC" VerticalAlignment="Center"/>
<Rectangle x:Name="VerticalLine" HorizontalAlignment="Center" Stroke="#FFCCCCCC" VerticalAlignment="Top" Width="1"/>
<ToggleButton x:Name="Expander" Background="{TemplateBinding Background}" IsTabStop="False"/>
<Grid x:Name="LoadingVisual" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5" Visibility="Collapsed" VerticalAlignment="Center">
<Grid.RenderTransform>
<TransformGroup>
<RotateTransform Angle="0" CenterY="0.5" CenterX="0.5"/>
</TransformGroup>
</Grid.RenderTransform>
<Path Data="M1,0A1,1,90,1,1,0,-1" Height="10" StrokeStartLineCap="Round" Stretch="Fill" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" Width="10"/>
<Path Data="M0,-1.1L0.1,-1 0,-0.9" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Left" Height="4" Margin="5,-1.5,0,0" Stretch="Fill" StrokeThickness="1" VerticalAlignment="Top" Width="4"/>
</Grid>
</Grid>
<CheckBox x:Name="CheckBoxElement" Grid.Column="2" IsTabStop="False" Visibility="Collapsed" HorizontalAlignment="Left" VerticalAlignment="Center" Style="{StaticResource UserTreeSettingCheckboxStyle}">
</CheckBox>
<RadioButton x:Name="RadioButtonElement" Grid.Column="2" IsTabStop="False" Margin="5,0,0,0" Visibility="Collapsed" VerticalAlignment="Center">
<telerik:StyleManager.Theme>
<telerik:Office_BlackTheme/>
</telerik:StyleManager.Theme>
</RadioButton>
<Image x:Name="Image" Grid.Column="3" HorizontalAlignment="Center" MaxWidth="16" MaxHeight="16" Margin="2" VerticalAlignment="Center"/>
<Rectangle x:Name="FocusVisual" Grid.ColumnSpan="6" Grid.Column="2" IsHitTestVisible="False" RadiusY="3" RadiusX="3" Stroke="Black" StrokeThickness="1" StrokeDashArray="1 2" Visibility="Collapsed"/>
<Grid Grid.ColumnSpan="2" Grid.Column="4">
<ContentPresenter x:Name="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
<ContentPresenter x:Name="EditHeaderElement" ContentTemplate="{TemplateBinding HeaderEditTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
<toolkit:TimePicker x:Name="TimeStart" Grid.Column="6" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Format="Custom" FormatString="HH:mm"/>
<toolkit:TimePicker x:Name="TimeEnd" Grid.Column="6" Height="Auto" HorizontalAlignment="Right" VerticalAlignment="Center" Format="Custom" FormatString="HH:mm"/>
</Grid>
<ItemsPresenter x:Name="ItemsHost" Grid.Row="1" Visibility="Collapsed"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsInEditMode" Value="True">
<Setter Property="Visibility" TargetName="Header" Value="Collapsed"/>
<Setter Property="Visibility" TargetName="EditHeaderElement" Value="Visible"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="IsChecked" TargetName="CheckBoxElement" Value="True"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="IsChecked" TargetName="CheckBoxElement" Value="True"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="#FF52686E"/>
</Trigger>
<Trigger Property="IsExpanded" Value="True">
<Setter Property="Visibility" TargetName="ItemsHost" Value="Visible"/>
</Trigger>
<Trigger Property="IsLoadingOnDemand" Value="True">
<Trigger.EnterActions>
<BeginStoryboard x:Name="LoadingVisualTransform">
<Storyboard>
<DoubleAnimation Duration="0:0:1" From="0" RepeatBehavior="Forever" To="359" Storyboard.TargetProperty="Angle" Storyboard.TargetName="LoadingVisualAngleTransform"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<StopStoryboard BeginStoryboardName="LoadingVisualTransform"/>
</Trigger.ExitActions>
<Setter Property="Visibility" TargetName="LoadingVisual" Value="Visible"/>
<Setter Property="Visibility" TargetName="Expander" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="#FF1E7787"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
运行此代码时的结果如下图所示
问题是两个第一个 TimePicker 不是与下面的“左对齐”。我想我可以设置他们的左边距来纠正它,但我不知道我必须设置的确切“左边距”值。
有人可以告诉我如何解决我的问题吗?
非常感谢!
电通