【问题标题】:I need to remove the highlight off of the radtreeview in WPF我需要从 WPF 中的 radtreeview 中删除突出显示
【发布时间】:2012-06-03 22:35:36
【问题描述】:

这是我的代码。我只需要取消 radtreeview 的亮点。我会像在其他人中那样使用 IsHitTestVisible,但是它不允许我单击触发器来扩展节点。 任何帮助将不胜感激。

 <telerik:RadTreeView x:Name="radTreeView" Margin="8" ItemsSource="{Binding Errors}" Background="Salmon" IsHitTestVisible="True" IsDropPreviewLineEnabled="False" IsDragTooltipEnabled="False" Focusable="False">
            <telerik:RadTreeView.ItemTemplate>
                 <HierarchicalDataTemplate ItemsSource="{Binding SubItems}" >
                    <Grid Background="Salmon">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>

                        </Grid.RowDefinitions>
                        <TextBlock Text="{Binding Description}" IsHitTestVisible="False" />

                        <ListBox Grid.Row="1" ItemsSource="{Binding Messages}" Margin="20,0,0,0" BorderBrush="#00000000" BorderThickness="0" Background="Salmon" IsHitTestVisible="False" >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Message}"/>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Grid>

                </HierarchicalDataTemplate>

            </telerik:RadTreeView.ItemTemplate>
        </telerik:RadTreeView>

【问题讨论】:

    标签: c# wpf telerik styles radtreeview


    【解决方案1】:

    从不同的角度接近它。您应该尝试在 TreeViewItem 上更改以下内容:

    • SystemColors.HighlightBrushKey
    • SystemColors.HighlightTextBrushKey

    例子:

    <Style TargetType="TreeViewItem">
          <Style.Resources>
              <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FFF"/>
              <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="#000"/>
         </Style.Resources>  
    </Style>
    

    这也适用于 Rad 控件。您只需要针对 RadTreeViewItem 进行调整。

    【讨论】:

    • 我应该把它放在我的代码中的什么地方?当我添加它时,异常“在使用 ItemsSource 之前,Items Collection 必须为空。”
    • 我认为我已经正确实现了它,但它仍然没有取消突出显示
    • 您确定更改了 TargetType 吗?
    猜你喜欢
    • 2013-05-29
    • 2018-03-31
    • 1970-01-01
    • 2021-07-16
    • 2014-01-02
    • 1970-01-01
    • 2011-08-31
    • 2011-09-04
    • 1970-01-01
    相关资源
    最近更新 更多