wpf 自定义控件-groupbox

cs 复制代码
<Application x:Class="ZGR.Databoard.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:ZGR.Databoard"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <!--  定义字体-->
        <FontFamily x:Key="Iconfont">Assets/Fonts/iconfont.ttf#iconfont</FontFamily>

        <Style TargetType="GroupBox" x:Key="GroupBoxStyle">
            <Setter Property="Margin" Value="10"></Setter>
            <Setter Property="Template" >
                <Setter.Value>
                    <ControlTemplate TargetType="GroupBox" >
                        <Border BorderBrush="#ddd" BorderThickness="1" CornerRadius="5" Background="#DDFBFAFD" >
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="45"></RowDefinition>
                                    <RowDefinition></RowDefinition>
                                </Grid.RowDefinitions>
                                <TextBlock  FontWeight="Bold" Foreground="#11135A" FontSize="14"  Margin="20,0" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{TemplateBinding Header}">
                                    <TextBlock.Effect>
                                        <DropShadowEffect  Direction="270" ShadowDepth="8" BlurRadius="20"  Color="#5766F6" Opacity="0.3"></DropShadowEffect>
                                    </TextBlock.Effect>
                                 <Border Height="2" Background="#DDD" VerticalAlignment="Bottom" ></Border>
                                </TextBlock>
                                <ContentPresenter Grid.RowSpan="2"></ContentPresenter>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


    </Application.Resources>
</Application>
cs 复制代码
     <GroupBox Header="各生产线生产量趋势">
         <Grid>
             <Grid.RowDefinitions>
                 <RowDefinition Height="45"/>
                 <RowDefinition Height="auto"/>
                 <RowDefinition/>
             </Grid.RowDefinitions>

             <Border CornerRadius="5" Background="#EAEAF7" 
                 VerticalAlignment="Center" HorizontalAlignment="Right"
                 Margin="15,0">
                 <Border.Resources>
                     <Style TargetType="RadioButton">
                         <Setter Property="Width" Value="40"/>
                         <Setter Property="Height" Value="25"/>
                         <Setter Property="Background" Value="Transparent"/>
                         <Setter Property="FontSize" Value="11"/>
                         <Setter Property="Template">
                             <Setter.Value>
                                 <ControlTemplate TargetType="RadioButton">
                                     <Border Background="{TemplateBinding Background}"
                                         CornerRadius="5">
                                         <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                     </Border>
                                 </ControlTemplate>
                             </Setter.Value>
                         </Setter>
                         <Style.Triggers>
                             <Trigger Property="IsChecked" Value="True">
                                 <Setter Property="Background" Value="#5665F4"/>
                                 <Setter Property="Foreground" Value="White"/>
                             </Trigger>
                         </Style.Triggers>
                     </Style>
                 </Border.Resources>
                 <Grid>
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition/>
                         <ColumnDefinition Width="auto"/>
                         <ColumnDefinition/>
                         <ColumnDefinition Width="auto"/>
                         <ColumnDefinition/>
                         <ColumnDefinition Width="auto"/>
                         <ColumnDefinition/>
                     </Grid.ColumnDefinitions>
                     <Border Background="#DDD" Width="1" Grid.Column="1" Margin="0,5"/>
                     <Border Background="#DDD" Width="1" Grid.Column="3" Margin="0,5"/>
                     <Border Background="#DDD" Width="1" Grid.Column="5" Margin="0,5"/>

                     <RadioButton Content="天" IsChecked="True"/>
                     <RadioButton Content="周" Grid.Column="2"/>
                     <RadioButton Content="月" Grid.Column="4"/>
                     <RadioButton Content="季度" Grid.Column="6"/>
                 </Grid>
             </Border>

             <StackPanel Orientation="Horizontal" VerticalAlignment="Center" 
                     HorizontalAlignment="Left" Grid.Row="1"
                     Margin="20,10" TextBlock.Foreground="#888">
                 <Border Width="10" Height="4" Background="#5966F1"/>
                 <TextBlock Text="生产线1" Margin="10,0,30,0"/>

                 <Border Width="10" Height="4" Background="#01BAC0"/>
                 <TextBlock Text="生产线2" Margin="10,0,30,0"/>

                 <Border Width="10" Height="4" Background="#FF7371"/>
                 <TextBlock Text="生产线3" Margin="10,0,30,0"/>

                 <Border Width="10" Height="4" Background="#FFC90C"/>
                 <TextBlock Text="生产线4" Margin="10,0,30,0"/>
             </StackPanel>


             <lvc:CartesianChart Grid.Row="2" Margin="20,10">
                 <!--调整序列-->
                 <lvc:CartesianChart.Series>
                     <lvc:LineSeries Values="22,28,38,35,30,21,32,40,39,35"
                                 LineSmoothness="0" PointGeometrySize="0"
                                 Stroke="#5966F1" Title="生产线1">
                         <lvc:LineSeries.Fill>
                             <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                 <GradientStop Color="#095770F0" Offset="0.5"/>
                                 <GradientStop Color="Transparent" Offset="1"/>
                             </LinearGradientBrush>
                         </lvc:LineSeries.Fill>
                     </lvc:LineSeries>

                     <lvc:LineSeries Values="13,14,21,15,21,15,22,20,25,33" 
                                 LineSmoothness="0" PointGeometrySize="0"
                                 Stroke="#03B9B7" Title="生产线2">
                         <lvc:LineSeries.Fill>
                             <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                 <GradientStop Color="#0903B9B7" Offset="0.5"/>
                                 <GradientStop Color="Transparent" Offset="1"/>
                             </LinearGradientBrush>
                         </lvc:LineSeries.Fill>
                     </lvc:LineSeries>

                     <lvc:LineSeries Values="8,9,10,9.5,9,9.5,12,8,13,7" 
                                 LineSmoothness="0" PointGeometrySize="0"
                                 Stroke="#FF7778" Title="生产线3">
                         <lvc:LineSeries.Fill>
                             <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                 <GradientStop Color="#09FF7778" Offset="0.5"/>
                                 <GradientStop Color="Transparent" Offset="1"/>
                             </LinearGradientBrush>
                         </lvc:LineSeries.Fill>
                     </lvc:LineSeries>

                     <lvc:LineSeries Values="4,2,5,4.5,5,4.5,6,7,2,4" 
                                 LineSmoothness="0" PointGeometrySize="0"
                                 Stroke="#FFCA06" Title="生产线3">
                         <lvc:LineSeries.Fill>
                             <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                 <GradientStop Color="#09FFCA06" Offset="0.5"/>
                                 <GradientStop Color="Transparent" Offset="1"/>
                             </LinearGradientBrush>
                         </lvc:LineSeries.Fill>
                     </lvc:LineSeries>
                 </lvc:CartesianChart.Series>

                 <!--调整X轴-->
                 <lvc:CartesianChart.AxisX>
                     <lvc:Axis Labels="09.01,09.02,09.03,09.04,09.05,09.06,09.07,09.08,09.09,09.10">
                         <lvc:Axis.Separator>
                             <lvc:Separator Step="1" StrokeThickness="0"/>
                         </lvc:Axis.Separator>
                     </lvc:Axis>
                 </lvc:CartesianChart.AxisX>

                 <!--调整Y轴-->
                 <lvc:CartesianChart.AxisY>
                     <lvc:Axis MinValue="0" MaxValue="50" 
                           LabelFormatter="{Binding YLableFormater}">
                         <lvc:Axis.Separator>
                             <lvc:Separator Step="10" Stroke="#DDD" StrokeThickness="0.5"/>
                         </lvc:Axis.Separator>
                     </lvc:Axis>
                 </lvc:CartesianChart.AxisY>

             </lvc:CartesianChart>

         </Grid>

     </GroupBox>
相关推荐
可喜~可乐3 小时前
C# WPF开发
microsoft·c#·wpf
界面开发小八哥4 小时前
DevExpress WPF中文教程:Grid - 如何移动和调整列大小?(二)
ui·.net·wpf·界面控件·devexpress·ui开发
界面开发小八哥4 小时前
「实战应用」如何用图表控件SciChart WPF实现应用程序的DPI感知?
信息可视化·wpf·数据可视化·图表·scichart wpf·scichart
生产队队长17 小时前
项目练习:element-ui的valid表单验证功能用法
前端·vue.js·ui
~央千澈~1 天前
优雅草央千澈-关于蓝湖如何快速的标注交互原型是如何使用的-如何使用蓝湖设计交互原型和整个软件项目的流程逻辑-实践项目详细说明
ui·交互·蓝湖
明耀2 天前
WPF TabControl 设置item不能点击
wpf
军训猫猫头2 天前
20.抽卡只有金,带保底(WPF) C#
ui·c#·wpf
明耀2 天前
WPF 设置平均布局 如果隐藏的话,能够自动扩展
wpf
wuningw2 天前
ant-design-ui的Select选择器多选时同时获取label与vaule值
ui·arcgis
SoraLuna2 天前
「Mac畅玩鸿蒙与硬件47」UI互动应用篇24 - 虚拟音乐控制台
开发语言·macos·ui·华为·harmonyos