精华内容
下载资源
问答
  • 要做一名负责任的资源搬运工 网上WPF样式设计不多 不像jQuery那样泛滥 故想多上传几个分享给大家 说实话我一个没什么艺术细胞的知道怎么做也做不好看
  • 使用WPF中的GroupBox控件时,如果背景色不是白色,那么会在GroupBox边框出现白边,这个项目包含了去除白边的Style。
  • WPF控件之GroupBox

    千次阅读 2017-06-21 17:06:29
    1、GroupBox继承自HeaderedContentControl类。 2、显示为具有圆角和标题的方框。 例: 3、注意,GroupBox仍需要布局容器(如StackPanel面板)来布置内容。GroupBox控件经常用对数量不多的相关控件进行分组...

    1、GroupBox继承自HeaderedContentControl类。

    2、显示为具有圆角和标题的方框。

    例:


    3、注意,GroupBox仍需要布局容器(如StackPanel面板)来布置内容。GroupBox控件经常用对数量不多的相关控件进行分组,如几个单选按钮。

    但GroupBox控件没有提供内置功能,因而可以随意使用。

    展开全文
  • WPF GroupBox样式

    千次阅读 2014-03-22 13:04:00
    来源:http://code.msdn.microsoft.com/WPF-GroupBox-Style-1d9df7c5/    效果:   XAML CODE: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ...

     来源:http://code.msdn.microsoft.com/WPF-GroupBox-Style-1d9df7c5/

     

     效果:

     

    XAML CODE:

    <Window
        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:ed="http://schemas.microsoft.com/expression/2010/drawing" mc:Ignorable="d"
        x:Class="WpfApplication1.MainWindow"
        x:Name="Window"
        Title="MainWindow"
        Width="640" Height="480" Style="{DynamicResource WindowStyle1}" WindowStyle="ThreeDBorderWindow" Icon="ihc_account_24.png" ResizeMode="CanResizeWithGrip" WindowStartupLocation="Manual" Cursor="Arrow" Background="#FFD4D4D4">
        <Window.Resources>
            <ControlTemplate x:Key="WindowTemplateKey" TargetType="{x:Type Window}">
                <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                    <Grid>
                        <AdornerDecorator>
                            <ContentPresenter/>
                        </AdornerDecorator>
                        <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
                    </Grid>
                </Border>
                <ControlTemplate.Triggers>
                    <MultiTrigger>
                        <MultiTrigger.Conditions>
                            <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
                            <Condition Property="WindowState" Value="Normal"/>
                        </MultiTrigger.Conditions>
                        <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
                    </MultiTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
            <Style x:Key="WindowStyle1" TargetType="{x:Type Window}">
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
                <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Window}">
                            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                                <AdornerDecorator>
                                    <ContentPresenter/>
                                </AdornerDecorator>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="ResizeMode" Value="CanResizeWithGrip">
                        <Setter Property="Template" Value="{StaticResource WindowTemplateKey}"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
            <BorderGapMaskConverter x:Key="BorderGapMaskConverter"/>
            <Style x:Key="GroupBoxStyle1" TargetType="{x:Type GroupBox}">
                <Setter Property="BorderBrush" Value="#D5DFE5"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type GroupBox}">
                            <Grid SnapsToDevicePixels="true">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="6"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="6"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto" MinHeight="59"/>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="6"/>
                                </Grid.RowDefinitions>
                                <Border BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="4" Grid.Column="0" CornerRadius="4" Grid.Row="0" Grid.RowSpan="4" Background="#FFE5E5E5" Margin="0,-0.25,0,0.25">
                                    <Border.Effect>
                                        <DropShadowEffect Color="#FFAAAAAA" Direction="350"/>
                                    </Border.Effect>
                                </Border>
                                <Border x:Name="Header" Grid.Column="1" Padding="3,1,3,0" Grid.Row="1" Grid.RowSpan="1" HorizontalAlignment="Right" Background="{x:Null}" Margin="0" Height="16.96" VerticalAlignment="Top"/>
                                <ContentPresenter Grid.ColumnSpan="2" Grid.Column="1" Margin="{TemplateBinding Padding}" Grid.Row="2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.RowSpan="1"/>
                                <Border BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="4" CornerRadius="4" Grid.Row="1" Grid.RowSpan="3">
                                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
                                        <Border BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/>
                                    </Border>
                                </Border>
                                <Grid x:Name="HeaderGrid" Height="47.2" VerticalAlignment="Stretch" Grid.Column="2" Grid.ColumnSpan="2" Grid.RowSpan="1" Margin="0,7.982,-16,3.818" Grid.Row="1" HorizontalAlignment="Right">
                                    <Path Data="M12.19,0 L12.290733,14.847 -1.3000648E-08,14.847 z" Height="16.1" Margin="0,0,8.067,0" RenderTransformOrigin="0.499999978361064,0.499999995889058" Stretch="Fill" Stroke="Black" StrokeThickness="0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="12.29" >
                                        <Path.Fill>
                                            <LinearGradientBrush EndPoint="0.466,2.201" StartPoint="0.5,0">
                                                <GradientStop Color="#C66A6A6A" Offset="1"/>
                                                <GradientStop Color="#E1434343" Offset="0.855"/>
                                                <GradientStop Color="#FFC6C6C6" Offset="0.11"/>
                                            </LinearGradientBrush>
                                        </Path.Fill>
                                        <Path.RenderTransform>
                                            <TransformGroup>
                                                <ScaleTransform/>
                                                <SkewTransform/>
                                                <RotateTransform Angle="90.087"/>
                                                <TranslateTransform Y="-6.04399277075815" X="6.0531771644038841"/>
                                            </TransformGroup>
                                        </Path.RenderTransform>
                                    </Path>
                                    <Border BorderBrush="Black" BorderThickness="0" Margin="0,8.061,0,0" CornerRadius="16,0,0,16" Background="White">
                                        <Border.Effect>
                                            <DropShadowEffect Direction="195" BlurRadius="10" Opacity="0.305" ShadowDepth="6"/>
                                        </Border.Effect>
                                        <Border x:Name="contentBorder" BorderBrush="Black" Margin="6,6,0,6" CornerRadius="16,0,0,16">
                                            <Border.Background>
                                                <LinearGradientBrush EndPoint="1.002,0.498" StartPoint="-0.024,0.502">
                                                    <GradientStop Color="#FF678B03" Offset="0.027"/>
                                                    <GradientStop Color="#FFA4C43D" Offset="0.948"/>
                                                    <GradientStop Color="#FFADCA54" Offset="0.969"/>
                                                    <GradientStop Color="#FFA7C646" Offset="0.975"/>
                                                    <GradientStop Color="#FFC9EF4C" Offset="0.994"/>
                                                </LinearGradientBrush>
                                            </Border.Background>
                                            <Grid>
                                                <ContentControl HorizontalAlignment="Left" Margin="20,0,23,0" d:LayoutOverrides="Height" VerticalAlignment="Center" Foreground="White">
                                                    <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="0" Width="212.323"/>
                                                </ContentControl>
                                            </Grid>
                                        </Border>
                                    </Border>
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Window.Resources>
    
        <Grid x:Name="LayoutRoot">
            <GroupBox Header="Contact Details" Margin="98.5,77,132.97,65.207" Style="{DynamicResource GroupBoxStyle1}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.285*"/>
                        <ColumnDefinition Width="0.041*"/>
                        <ColumnDefinition Width="0.674*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="27.553"/>
                        <RowDefinition Height="28.502"/>
                        <RowDefinition Height="29.424"/>
                        <RowDefinition Height="96.521"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock HorizontalAlignment="Right" TextWrapping="Wrap" Text="Name:" VerticalAlignment="Center"/>
                    <TextBlock HorizontalAlignment="Right" TextWrapping="Wrap" Text="Phone:" VerticalAlignment="Center" Margin="0" Grid.Row="1"/>
                    <TextBlock HorizontalAlignment="Right" TextWrapping="Wrap" Text="Email:" VerticalAlignment="Center" Margin="0" Grid.Row="2"/>
                    <TextBlock HorizontalAlignment="Right" TextWrapping="Wrap" Text="Address:" VerticalAlignment="Center" Margin="0" Grid.Row="3"/>
                    <TextBox Margin="0,0,18.241,0" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Column="2" Height="24"/>
                    <TextBox Margin="0,0,18.241,0" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Column="2" Height="24" Grid.Row="1"/>
                    <TextBox Margin="0,0,18.241,0" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Column="2" Height="24" Grid.Row="2"/>
                    <TextBox Margin="0,0,18.241,0" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Column="2" Height="89" Grid.Row="3"/>
                </Grid>
            </GroupBox>
            <Grid Height="60.061" Margin="248,58.633,208,0" VerticalAlignment="Top" Visibility="Collapsed">
                <Path Data="M12.19,0 L12.290733,14.847 -1.3000648E-08,14.847 z" Height="16.1" Margin="0,0,8.067,0" RenderTransformOrigin="0.499999978361064,0.499999995889058" Stretch="Fill" Stroke="Black" StrokeThickness="0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="12.29" >
                    <Path.Fill>
                        <LinearGradientBrush EndPoint="0.466,2.201" StartPoint="0.5,0">
                            <GradientStop Color="#FF5F6061" Offset="1"/>
                            <GradientStop Color="#FF757576" Offset="0.855"/>
                            <GradientStop Color="#FFD1D1D1" Offset="0.11"/>
                        </LinearGradientBrush>
                    </Path.Fill>
                    <Path.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform Angle="90.087"/>
                            <TranslateTransform Y="-6.04399277075815" X="6.0531771644038841"/>
                        </TransformGroup>
                    </Path.RenderTransform>
                </Path>
                <Border BorderBrush="Black" BorderThickness="0" Margin="0,8.061,0,0" CornerRadius="16,0,0,16" Background="White">
                    <Border.Effect>
                        <DropShadowEffect Direction="195" BlurRadius="10" Opacity="0.305" ShadowDepth="6"/>
                    </Border.Effect>
                    <Border BorderBrush="Black" Margin="6,6,0,6" CornerRadius="16,0,0,16">
                        <Border.Background>
                            <LinearGradientBrush EndPoint="1.002,0.498" StartPoint="-0.024,0.502">
                                <GradientStop Color="#FF678B03" Offset="0.027"/>
                                <GradientStop Color="#FFA4C43D" Offset="0.948"/>
                                <GradientStop Color="#FFADCA54" Offset="0.969"/>
                                <GradientStop Color="#FFA7C646" Offset="0.975"/>
                                <GradientStop Color="#FFC9EF4C" Offset="0.994"/>
                            </LinearGradientBrush>
                        </Border.Background>
                        <Grid/>
                    </Border>
                </Border>
            </Grid>
        </Grid>
    </Window>
    View Code

     

    Code Download

     

     

     

     

     

    展开全文
  • WPFGroupBox样式_边框透明XAML:GroupBox引用:效果:使用前:使用后: XAML: <BorderGapMaskConverter x:Key="BorderGapMaskConverter"/> <Style x:Key="GroupboxWithoutBorder" TargetType="{x:Type ...

    WPF之GroupBox样式_边框透明

    XAML:

    <BorderGapMaskConverter x:Key="BorderGapMaskConverter"/>
            <Style x:Key="GroupboxWithoutBorder" TargetType="{x:Type GroupBox}">
                <Setter Property="BorderBrush" Value="#D5DFF5"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type GroupBox}">
                            <Grid SnapsToDevicePixels="True">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="6"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="6"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="6" />
                                </Grid.RowDefinitions>
                                <Border CornerRadius="4" Grid.Row="1" Grid.RowSpan="3" Grid.Column="0" Grid.ColumnSpan="4" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" Background="{TemplateBinding Background}" />
                                <Border x:Name="Header" Padding="3,1,3,0" Grid.Row="0" Grid.RowSpan="2" Grid.Column="1">
                                    <ContentPresenter ContentSource="Header" RecognizesAccessKey="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                </Border>
                                <ContentPresenter Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                <Border Grid.Row="1" Grid.RowSpan="3" Grid.ColumnSpan="4"  BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="3">
                                    <Border.OpacityMask>
                                        <MultiBinding Converter="{StaticResource BorderGapMaskConverter}" ConverterParameter="7">
                                            <Binding ElementName="Header" Path="ActualWidth" />
                                            <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
                                            <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
                                        </MultiBinding>
                                    </Border.OpacityMask>
                                </Border>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="FocusVisual">
                <Setter Property="Control.Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <LinearGradientBrush x:Key="TabItem.Static.Background" EndPoint="0,1" StartPoint="0,0">
                <GradientStop Color="#F0F0F0" Offset="0.0"/>
                <GradientStop Color="#E5E5E5" Offset="1.0"/>
            </LinearGradientBrush>
            <SolidColorBrush x:Key="TabItem.Static.Border" Color="#ACACAC"/>
            <LinearGradientBrush x:Key="TabItem.MouseOver.Background" EndPoint="0,1" StartPoint="0,0">
                <GradientStop Color="#ECF4FC" Offset="0.0"/>
                <GradientStop Color="#DCECFC" Offset="1.0"/>
            </LinearGradientBrush>
            <SolidColorBrush x:Key="TabItem.MouseOver.Border" Color="#7EB4EA"/>
            <SolidColorBrush x:Key="TabItem.Disabled.Background" Color="#F0F0F0"/>
            <SolidColorBrush x:Key="TabItem.Disabled.Border" Color="#D9D9D9"/>
            <SolidColorBrush x:Key="TabItem.Selected.Border" Color="#ACACAC"/>
            <SolidColorBrush x:Key="TabItem.Selected.Background" Color="#FFFFFF"/>
            <Style x:Key="TabItemStyle1" TargetType="{x:Type TabItem}">
                <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
                <Setter Property="Foreground" Value="Black"/>
                <Setter Property="Background" Value="{StaticResource TabItem.Static.Background}"/>
                <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}"/>
                <Setter Property="Margin" Value="0"/>
                <Setter Property="Padding" Value="6,2,6,2"/>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabItem}">
                            <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
                                <Border x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Background="{TemplateBinding Background}" Margin="0">
                                    <Border x:Name="innerBorder" BorderBrush="{StaticResource TabItem.Selected.Border}" BorderThickness="1,1,1,0" Background="{StaticResource TabItem.Selected.Background}" Margin="-1" Opacity="0"/>
                                </Border>
                                <ContentPresenter x:Name="contentPresenter" ContentSource="Header" Focusable="False" HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                                    <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                                    <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                                    <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                                    <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Panel.ZIndex" Value="1"/>
                                    <Setter Property="Margin" Value="-2,-2,0,-2"/>
                                    <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Panel.ZIndex" Value="1"/>
                                    <Setter Property="Margin" Value="-2,0,-2,-2"/>
                                    <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Panel.ZIndex" Value="1"/>
                                    <Setter Property="Margin" Value="0,-2,-2,-2"/>
                                    <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                        <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="Panel.ZIndex" Value="1"/>
                                    <Setter Property="Margin" Value="-2,-2,-2,0"/>
                                    <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                                    <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                                    <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                                </MultiDataTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    

    GroupBox引用:

    Style="{StaticResource GroupboxWithoutBorder}"
    

    效果:

    使用前:

    在这里插入图片描述

    使用后:


    再将 BorderBrush 设置为“无画笔”
    在这里插入图片描述

    展开全文
  • Wpf GroupBox 分组 带标题 HeaderedContentControl 带标题的内容控件 只能有一个子元素作为它的内容 Content Header 边框 结合布局控件(容器) 分组显示 2.具体案例 <Window x:Class="WpfAppTest.GroupBoxWindow...

    1.Grid 控件介绍

    Winform Groupbox 分组容器控件

    Wpf GroupBox 分组 带标题 HeaderedContentControl 带标题的内容控件

    只能有一个子元素作为它的内容 Content Header 边框

    结合布局控件(容器)

    分组显示

    2.具体案例

    <Window x:Class="WpfAppTest.GroupBoxWindow"
            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:WpfAppTest"
            mc:Ignorable="d"
            Title="GroupBoxWindow" Height="450" Width="800" Loaded="Window_Loaded">
            <Grid>
                    <!-- 分组控件  内容控件   只能有一个元素作为它的Content
                         如果我想在它的内部呈放多个子元素????   ——布局控件   -容纳多个元素
                    -->
                    <GroupBox  Header="导航菜单"  Width="200"  Height="200" BorderThickness="2" BorderBrush="Red">
                            <StackPanel>
                                    <Label Content="这是一个GroupBox控件"/>
                                    <Label Content="这是一个GroupBox控件"/>
                                    <Label Content="这是一个GroupBox控件"/>
                                    <Label Content="这是一个GroupBox控件"/>
                            </StackPanel>
                    </GroupBox>
                    <GroupBox  Header="导航菜单2"  Width="221"  Height="200" BorderThickness="2" BorderBrush="Red" Margin="32,110,0,0" HorizontalAlignment="Left"  VerticalAlignment="Top" Name="gbInfo">
                            <StackPanel Orientation="Vertical" >
                                    <StackPanel Orientation="Horizontal" >
                                            <Label Content="用户名:"/>
                                            <TextBox Name="txtUserName" Text="userName"  Width="150"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
                                            <Label Content="密码:"/>
                                            <PasswordBox Password="123456"  Width="150"/>
                                    </StackPanel>
                            </StackPanel>
                    </GroupBox>
            </Grid>
    </Window>
    
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
            //如果我们没有设置TextBox的name属性,通过GroupBox控件去获取
            StackPanel spFirst = gbInfo.Content as StackPanel;
            foreach(var ele in  spFirst.Children)
            {
                    StackPanel sp = ele as StackPanel;
                    foreach(var ele2 in sp.Children)
                    {
                            if(ele2 is TextBox)
                            {
                                    TextBox txt = ele2 as TextBox;
                                    string name = txt.Text;
                            }
                    }
            }
    
            string name1 = txtUserName.Text;//直接通过name属性获取控件的Text  
    }
    
    展开全文
  • GroupBox 表示一个控件,该控件用于创建具有用户界面 (UI) 内容边框和标题的容器。 下图是一个的示例GroupBox,它包含一个TabControl和一个括在StackPanel中的Button。 若要对多个GroupBox控件应用相同的属性...
  • Strech GroupBox Widht + WPF

    2021-04-02 20:45:51
    尝试使用DockPanel并将GroupBox放入其中。 VerticalAlignment =“ Stretch”> DockPanel.Dock =“顶部” />
  • WPF中内容控件的用法,包括GroupBox组合框控件,Expander控件,TabControl标签控件
  • WPF入门教程系列十九——ListView示例(一) WPF的菜单栏,工具栏的简单使用 一、控件到底是什么? 控件:能够展示数据,响应用户操作的UI元素。 控件分为6类: 1、布局控件:容纳多个控件或嵌套其他布局控件,...
  • WPF GroupBox 样式分享

    2015-10-30 11:59:00
    WPFGroupBox样式分享 原文:WPFGroupBox样式分享 默认样式 添加样式后 样式代码: <Style TargetType="{x:Type ...GroupBox}"> <Setter Property="BorderBrush" Value="#D...
  • http://www.cnblogs.com/KeenLeung/p/3617426.html 来源:http://code.msdn.microsoft.com/WPF-GroupBox-Style-1d9df7c5/ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  • WPF学习

    万次阅读 多人点赞 2019-03-05 22:00:17
    首先感谢刘铁锰先生的《深入浅出WPF》,学习WPF过程碰上很多新概念,如Data Binding、路由事件,命令、各种模板等。 WPF:编写CS端的UI技术。 怎么去掉WPF窗体靠上多出黑色的长条?在vs界面的菜单栏点击调试-选项...
  • 自定义GroupBox

    2018-06-06 15:48:18
    如图为自定义GroupBox样式。 代码如下: &lt;Style x:Key="myGroup" TargetType="{x:Type GroupBox}"&gt;  &lt;Setter Property="Header" Value="这里是标题&...
  • C#自定义控件案例--美化GroupBox(十分经典)
  • WPF开发教程

    万次阅读 多人点赞 2019-07-02 23:13:20
    ------WPF开发教程 目录 WPF基础入门.... 3 1. WPF基础之体系结构... 3 2. WPF基础之XAML. 9 3. WPF基础之基元素... 23 4. WPF基础之属性系统... 26 5. WPF基础之路由事件... 33 6. WPF基础之布局系统... ...
  • <Window x:Class="WpfApplication1.Window1"  xmlns=" http://schemas.microsoft.com/winfx/2006/xaml/presentation "  xmlns:x=" http://schemas.microsoft.com/winfx/2006/xaml "  Title="Window1" ...
  • .Net 中对GroupBox,Expander在WPF中的简单应用
  • 带标题的文本控件带标题的文本控件,GroupBox\Expander\ItemControl,共同点是: 1.有标题Header 2.有文本,可以更复杂,在布局控件内更多元素来表达文本GroupBoxGroupBox简单示例,没有特殊的属性 <GroupBox ...
  • WPF样式

    千次阅读 2019-06-22 16:21:18
    WPF相对于Windows客户端的开发来说,向前跨出了巨大的一步,它提供了超丰富的.NET UI 框架,集成了矢量图形,丰富的流动文字支持(flow text support),3D视觉效果和强大无比的控件模型框架。 Windows Presentation ...
  • Bootstrap风格的WPF样式

    2020-09-01 01:11:25
    此样式基于bootstrap-3.3.0,样式文件里的源码行数都是指的这个版本.这篇文章主要介绍了Bootstrap风格的WPF样式的相关资料,需要的朋友参考下
  • groupbox加上滚动条

    热门讨论 2010-02-10 10:49:43
    这是一个用c#开发,简单的给groupbox加上滚动条的代码,可以举一反三,以后如果哪个控件没有自动出现滚动条的功能,皆可以用这个方法实现
  • c# 如何遍历groupbox中所有对象
  • 为了使WPF程序在不同版本的操作系统上保持一致的显示效果,我们需要重写WPF控件样式。这篇博客将展示如何创建一个Metro Style的WPF窗体。 首先先看一下最终窗体的效果图, 通过截图我们可以看出来这个窗体由两...
  • So Long Time Not Write Essay Hope My Fans Don't Leave Me ???? 今天给大家带来一款自己写的GrouBox希望我的粉丝们喜欢! <...--自定义的GroupBox--> <Style TargetType="Grou...
  • Wpf GroupBox 分组 带标题 HeaderedContentControl 带标题的内容控件 只能有一个子元素作为它的内容 Content Header 边框 结合布局控件(容器) 分组显示 2.具体案例 <Window x:Class="WpfAppTest.GroupBoxWindow...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,120
精华内容 448
关键字:

groupboxwpf