0

我从 RadDataForm 中删除了页眉、页脚和边框:

<t:RadDataForm ItemsSource="{Binding Item}" MinHeight="300" MinWidth="300" 
               AutoEdit="True" BorderThickness="0" Background="Transparent"
               CommandButtonsVisibility="None" BorderBrush="Transparent" 
               ValidationSummaryVisibility="Collapsed" />

但是仍然存在两条线。如何去除水平线? 在此处输入图像描述

4

1 回答 1

1

您是否尝试过使用 Blend 来设置控件的样式?请注意,我使用的是 Silverlight,但应该是一样的。

但是,将此属性放入您的 RadDataForm 控件中:

Style="{StaticResource RadDataFormStyle1}"

现在它应该是这样的:

<t:RadDataForm ItemsSource="{Binding Item}" MinHeight="300" MinWidth="300" 
           AutoEdit="True" BorderThickness="0" Background="Transparent"
           CommandButtonsVisibility="None" BorderBrush="Transparent" 
           ValidationSummaryVisibility="Collapsed" 
           Style="{StaticResource RadDataFormStyleNoBorders}" />

现在您必须设置样式资源。您可以将样式资源放入 app.xaml 或控件的同一页面中。例如我有一个sdk:Page. 要将样式嵌入到控件的同一页面中,您必须执行以下操作:

<sdk:Page 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
  xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
  xmlns:t="http://schemas.telerik.com/2008/xaml/presentation"
  [other page things...]
......>


<!-- COPY FROM HERE, REPLACE ALL "telerik:" with yours "t:" and "sdk:" with your page namespace -->    

    <sdk:Page.Resources>
    <SolidColorBrush x:Key="DataForm_HeaderOuterBorder" Color="#FF282828"/>
    <SolidColorBrush x:Key="DataForm_HeaderInnerBorder" Color="#FFB5B5B5"/>
    <LinearGradientBrush x:Key="DataForm_HeaderBackground" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FF5B5B5B" Offset="1"/>
        <GradientStop Color="#FF868686"/>
        <GradientStop Color="#FF4F4F4F" Offset="0.42"/>
        <GradientStop Color="#FF0E0E0E" Offset="0.43"/>
    </LinearGradientBrush>
    <SolidColorBrush x:Key="DataForm_HeaderForeground" Color="White"/>
    <Telerik_Windows_Controls_Data_DataForm:DescriptionVisibilityConverter x:Key="DescriptionVisibilityConverter"/>
    <SolidColorBrush x:Key="DataFormPanel_Border" Color="#FF848484"/>
    <LinearGradientBrush x:Key="DataForm_FooterPanel_Background" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFB5B5B5"/>
        <GradientStop Color="#FFF0F0F0" Offset="0.5"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="Background_Disabled" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#7F000000"/>
        <GradientStop Color="#7F000000" Offset="1"/>
        <GradientStop Color="#33000000" Offset="0.5"/>
    </LinearGradientBrush>
    <telerik:InvertedBooleanToVisibilityConverter x:Key="InvertedBooleanToVisibilityConverter"/>
    <ControlTemplate x:Key="RadDataFormTemplate" TargetType="telerik:RadDataForm">
        <Border x:Name="PART_RootElement" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
            <Grid x:Name="PART_DataFormGrid" Background="{TemplateBinding Background}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Border x:Name="Header" BorderBrush="{StaticResource DataForm_HeaderOuterBorder}" BorderThickness="1" Margin="-1,-1,-1,0" Visibility="{Binding Header, Converter={StaticResource DescriptionVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}">
                    <Border BorderBrush="{StaticResource DataForm_HeaderInnerBorder}" BorderThickness="1" Background="{StaticResource DataForm_HeaderBackground}">
                        <ContentControl x:Name="PART_ContentPresenter" Content="{TemplateBinding Header}" Foreground="{StaticResource DataForm_HeaderForeground}" FontWeight="Bold" HorizontalContentAlignment="Stretch" Margin="4,6,4,6" VerticalAlignment="Center" VerticalContentAlignment="Top"/>
                    </Border>
                </Border>
                <Telerik_Windows_Controls_Data_DataForm:CollectionNavigator x:Name="CollectionNavigator" Grid.Row="1" telerik:StyleManager.Theme="{StaticResource Theme}" BorderBrush="{x:Null}"/>
                <Border BorderThickness="0,0,0,1" Grid.Row="2">
                    <ScrollViewer x:Name="PART_ItemsScrollViewer" ScrollViewer.HorizontalScrollBarVisibility="Auto" IsTabStop="False" telerik:StyleManager.Theme="{StaticResource Theme}" ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <StackPanel Orientation="Vertical">
                            <Telerik_Windows_Controls_Data_DataForm:AutoGeneratedFieldsPresenter x:Name="PART_AutoGeneratedFieldsPresenter" AutoGenerateFields="{Binding AutoGenerateFields, RelativeSource={RelativeSource TemplatedParent}}" CurrentItem="{Binding CurrentItem}" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                            <ContentPresenter x:Name="PART_FieldsContentPresenter" Content="{Binding CurrentItem}"/>
                        </StackPanel>
                    </ScrollViewer>
                </Border>
                <Telerik_Windows_Controls_Data_DataForm:DataFormValidationSummary x:Name="PART_ValidationSummary" Grid.Row="3" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{TemplateBinding ValidationSummaryVisibility}"/>
                <Border x:Name="FooterPanel_Background" Background="{StaticResource DataForm_FooterPanel_Background}" Grid.Row="4">
                    <StackPanel x:Name="PART_FooterPanel" HorizontalAlignment="Right" Orientation="Horizontal">
                        <telerik:RadButton x:Name="PART_CommitButton" Content="{TemplateBinding CommitButtonContent}" Command="controls:RadDataFormCommands.CommitEdit" Margin="2,4,4,4" MinWidth="48" MinHeight="20" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding CommitButtonVisibility}"/>
                        <telerik:RadButton x:Name="PART_CancelButton" Content="{TemplateBinding CancelButtonContent}" Command="controls:RadDataFormCommands.CancelEdit" Margin="2,4,4,4" MinWidth="48" MinHeight="20" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding CancelButtonVisibility}"/>
                    </StackPanel>
                </Border>
                <Border x:Name="Background_Disabled" Background="{StaticResource Background_Disabled}" IsHitTestVisible="False" Grid.RowSpan="5" Visibility="{Binding IsEnabled, Converter={StaticResource InvertedBooleanToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}"/>
            </Grid>
        </Border>
    </ControlTemplate>
    <SolidColorBrush x:Key="DataField_Foreground" Color="Black"/>
    <Style x:Key="RadDataFormNoBorders" TargetType="telerik:RadDataForm">
        <Setter Property="Template" Value="{StaticResource RadDataFormTemplate}"/>
        <Setter Property="Foreground" Value="{StaticResource DataField_Foreground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlOuterBorder}"/>
        <Setter Property="Background" Value="{StaticResource ControlBackground}"/>
        <Setter Property="BorderThickness" Value="1"/>
    </Style>
</sdk:Page.Resources>

<!-- STOP COPING HERE, NOW YOU CAN PASTE, REMEMBER TO REPLACE --> ........ 

或者,您可以尝试使用 Telerik 提供的主题属性:

 telerik:Theming.Theme="Transparent"

此属性允许您不对控件设置样式,但它会更改所有控件的外观,并且您可能不喜欢此主题。

于 2012-07-05T14:14:47.097 回答