首页 > 代码库 > WPF自定义仪表盘控件
WPF自定义仪表盘控件
闲来无事,分享一个仪表盘
源码: 直接复制代码即可运行,=。=!
<Window x:Class="TGP.InstrumentationDemo.MainWindow" 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:TGP.InstrumentationDemo" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525" Icon="logo-icon.png"> <Window.Resources> <Style TargetType="{x:Type TextBlock}"> <Setter Property="FontFamily" Value=http://www.mamicode.com/"微软雅黑"/> <Setter Property="FontWeight" Value=http://www.mamicode.com/"Bold"/> <Setter Property="Foreground" Value=http://www.mamicode.com/"Honeydew"/> <Setter Property="FontSize" Value=http://www.mamicode.com/"10"/> </Style> </Window.Resources> <Grid> <Grid Width="300" Height="300" HorizontalAlignment="Center" VerticalAlignment="Center" > <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="4"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="4"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid Width="300" Height="300" Grid.RowSpan="3" Grid.ColumnSpan="3"> <Grid.ColumnDefinitions> <!--外圈--> <ColumnDefinition Width="25"/> <ColumnDefinition Width="3"/> <ColumnDefinition Width="5"/> <ColumnDefinition Width="12"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="30"/> <ColumnDefinition Width="20"/> <ColumnDefinition Width="2"/> <ColumnDefinition Width="20"/> <ColumnDefinition Width="30"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="12"/> <ColumnDefinition Width="5"/> <ColumnDefinition Width="3"/> <ColumnDefinition Width="25"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="25"/> <RowDefinition Height="3"/> <RowDefinition Height="5" /> <RowDefinition Height="12"/> <RowDefinition Height="*"/> <RowDefinition Height="30"/> <RowDefinition Height="20"/> <RowDefinition Height="2"/> <RowDefinition Height="20"/> <RowDefinition Height="30" /> <RowDefinition Height="*"/> <RowDefinition Height="12"/> <RowDefinition Height="5"/> <RowDefinition Height="3"/> <RowDefinition Height="25"/> </Grid.RowDefinitions> <Ellipse Stroke="#FF27A6E2" Grid.RowSpan="15" Grid.ColumnSpan="15" Margin="0"> <Ellipse.Fill> <RadialGradientBrush> <GradientStop Color="Black" Offset="0.1"/> <GradientStop Color="Black" Offset="0.75"/> <GradientStop Color="#FF3E3737" Offset="0.85"/> <GradientStop Color="#FF353535" Offset="0.80"/> <GradientStop Color="#FF787272" Offset="0.93"/> <GradientStop Color="#FF303030" Offset="1"/> </RadialGradientBrush> </Ellipse.Fill> </Ellipse> <Ellipse Grid.Column="1" Fill="White" Margin="0" Grid.Row="1" Grid.RowSpan="13" Stroke="#FF27A6E2" Grid.ColumnSpan="13"/> <Ellipse Stroke="#FF27A6E2" Grid.Row="2" d:LayoutOverrides="HorizontalAlignment" Grid.Column="2" Grid.ColumnSpan="11" Grid.RowSpan="11" Margin="0"> <Ellipse.Fill> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF363535" Offset="0"/> <GradientStop Color="#FF363535" Offset="1"/> <GradientStop Color="#FF3C3A3A" Offset="0.5"/> </LinearGradientBrush> </Ellipse.Fill> </Ellipse> <Border Grid.Column="6" Grid.ColumnSpan="3"> <TextBlock TextWrapping="Wrap" Text="360°" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Row="6" Grid.RowSpan="3" Margin="1.201,0,0,0"> <TextBlock TextWrapping="Wrap" Text="270°" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Border Grid.Row="14" Grid.ColumnSpan="3" Grid.Column="6"> <TextBlock TextWrapping="Wrap" Text="180°" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Row="6" Grid.Column="14" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text="90°" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="90"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Rectangle Grid.Column="7" Margin="0.062,0,0,-0.25" Grid.Row="2" Stroke="White" Fill="White" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="7" Grid.Row="12" Stroke="White" Fill="White" Margin="0.062,0,0,-0.001" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="2" Fill="White" Grid.Row="7" Stroke="White" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="12" Fill="White" Grid.Row="7" Stroke="White" Margin="0.25,0,0,0" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Ellipse Grid.Column="5" Grid.Row="5" Grid.RowSpan="5" Grid.ColumnSpan="5"> <Ellipse.Fill> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF817B7B" Offset="0"/> <GradientStop Color="#FF977C7C" Offset="1"/> <GradientStop Color="#FF939090" Offset="0.584"/> </LinearGradientBrush> </Ellipse.Fill> </Ellipse> <Ellipse Grid.ColumnSpan="3" Grid.Column="6" Grid.Row="6" Grid.RowSpan="3" Stroke="#FF272727" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"> <Ellipse.Fill> <RadialGradientBrush> <GradientStop Color="White" Offset="0"/> <GradientStop Color="#FF343434" Offset="1"/> </RadialGradientBrush> </Ellipse.Fill> </Ellipse> <Border Grid.Column="6" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="3" Width="32" > <TextBlock TextWrapping="Wrap" Text="N" Foreground="Red" Height="13.197" Width="8.48"/> </Border> <Border Grid.Column="3" Grid.Row="6" HorizontalAlignment="Center" VerticalAlignment="Center" Height="32" Margin="0.618,0" Grid.RowSpan="3" d:LayoutOverrides="LeftMargin, RightMargin" > <TextBlock TextWrapping="Wrap" Text="W" RenderTransformOrigin="0.5,0.5" Height="13.197" Width="10.763"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Border Grid.Column="11" Grid.Row="6" HorizontalAlignment="Center" VerticalAlignment="Center" Height="32" Grid.RowSpan="3" Width="12" RenderTransformOrigin="0.5,0.5"> <Border.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="90"/> <TranslateTransform/> </TransformGroup> </Border.RenderTransform> <TextBlock TextWrapping="Wrap" Text="E" Height="13.197" Width="5.717"/> </Border> <Border Grid.Column="6" Grid.Row="11" Grid.ColumnSpan="3"> <TextBlock TextWrapping="Wrap" Text="S" Height="13.197" Width="6.017"/> </Border> <Border Grid.ColumnSpan="3" Grid.Column="6" Grid.Row="4"> <TextBlock TextWrapping="Wrap" Text="北" Width="10" VerticalAlignment="Bottom"/> </Border> <Border Grid.Column="4" Grid.Row="6" Grid.RowSpan="3" Height="30.098" Margin="0,1.902,0,0"> <TextBlock TextWrapping="Wrap" Text="西" Width="10" VerticalAlignment="Center" HorizontalAlignment="Right" RenderTransformOrigin="0.5,0.5" Margin="0"/> </Border> <Border Grid.ColumnSpan="3" Grid.Column="6" Grid.Row="10" Width="28.5"> <TextBlock TextWrapping="Wrap" Text="南" VerticalAlignment="Top" HorizontalAlignment="Center"/> </Border> <Border Grid.Column="10" Grid.Row="6" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text="东" Height="13.197" Width="10" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Center"/> </Border> </Grid> <Grid Width="300" Height="300" RenderTransformOrigin="0.5,0.5" Grid.RowSpan="3" Grid.ColumnSpan="3"> <Grid.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="22.5"/> <TranslateTransform/> </TransformGroup> </Grid.RenderTransform> <Grid.ColumnDefinitions> <!--外圈--> <ColumnDefinition Width="25"/> <ColumnDefinition Width="3"/> <ColumnDefinition Width="5"/> <ColumnDefinition Width="12"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="30"/> <ColumnDefinition Width="20"/> <ColumnDefinition Width="2"/> <ColumnDefinition Width="20"/> <ColumnDefinition Width="30"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="12"/> <ColumnDefinition Width="5"/> <ColumnDefinition Width="3"/> <ColumnDefinition Width="25"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="25"/> <RowDefinition Height="3"/> <RowDefinition Height="5" /> <RowDefinition Height="12"/> <RowDefinition Height="*"/> <RowDefinition Height="30"/> <RowDefinition Height="20"/> <RowDefinition Height="2"/> <RowDefinition Height="20"/> <RowDefinition Height="30" /> <RowDefinition Height="*"/> <RowDefinition Height="12"/> <RowDefinition Height="5"/> <RowDefinition Height="3"/> <RowDefinition Height="25"/> </Grid.RowDefinitions> <Border Grid.Column="6" Grid.ColumnSpan="3"> <TextBlock TextWrapping="Wrap" Text="22.5°" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Row="6" Grid.RowSpan="3" Margin="1.201,0,0,0"> <TextBlock TextWrapping="Wrap" Text="292.5°" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="-5,0"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Border Grid.Row="14" Grid.ColumnSpan="3" Grid.Column="6"> <TextBlock TextWrapping="Wrap" Text="202.5°" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Row="6" Grid.Column="14" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text="112.5°" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="-5,0"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Rectangle Grid.Column="7" Margin="0.062,0,0,-0.25" Grid.Row="2" Stroke="White" Fill="White" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="7" Grid.Row="12" Stroke="White" Fill="White" Margin="0.062,0,0,-0.001" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="2" Fill="White" Grid.Row="7" Stroke="White" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="12" Fill="White" Grid.Row="7" Stroke="White" Margin="0.25,0,0,0" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Border Grid.Column="6" Grid.Row="3" Grid.ColumnSpan="3" > <TextBlock TextWrapping="Wrap" Text="NNE" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Column="1" Grid.Row="6" Margin="0,-8,-14,-10" Grid.RowSpan="3" Grid.ColumnSpan="3" > <TextBlock TextWrapping="Wrap" Text="WNW" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Border Grid.Column="11" Grid.Row="6" Grid.RowSpan="3" RenderTransformOrigin="0.5,0.5" Grid.ColumnSpan="2" Margin="-3.867,-0.263,1.161,0.263"> <Border.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="89"/> <TranslateTransform/> </TransformGroup> </Border.RenderTransform> <TextBlock TextWrapping="Wrap" Text="ESE" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Margin="-7.493,-10.331,-7.507,0.331" Grid.Column="6" Grid.Row="11" Grid.ColumnSpan="3" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text="SSW" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.ColumnSpan="3" Grid.Column="6" Grid.Row="4" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock TextWrapping="Wrap" Text="北
东
北" VerticalAlignment="Bottom" HorizontalAlignment="Center"/> </Border> <Border Grid.Column="4" Grid.Row="6" Grid.RowSpan="3" Height="30.098" Margin="0,1.902,0,0"> <TextBlock TextWrapping="Wrap" Text="西 西 北 " RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Right" VerticalAlignment="Center"/> </Border> <Border Grid.ColumnSpan="3" Grid.Column="6" Grid.Row="10" Width="28.5"> <TextBlock TextWrapping="Wrap" Text="南
西
南" HorizontalAlignment="Center"/> </Border> <Border Grid.Column="10" Grid.Row="6" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text=" 东 东 南" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Center"/> </Border> </Grid> <Grid Width="300" Height="300" RenderTransformOrigin="0.5,0.5" Grid.RowSpan="3" Grid.ColumnSpan="3"> <Grid.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="45"/> <TranslateTransform/> </TransformGroup> </Grid.RenderTransform> <Grid.ColumnDefinitions> <!--外圈--> <ColumnDefinition Width="25"/> <ColumnDefinition Width="3"/> <ColumnDefinition Width="5"/> <ColumnDefinition Width="12"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="30"/> <ColumnDefinition Width="20"/> <ColumnDefinition Width="2"/> <ColumnDefinition Width="20"/> <ColumnDefinition Width="30"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="12"/> <ColumnDefinition Width="5"/> <ColumnDefinition Width="3"/> <ColumnDefinition Width="25"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="25"/> <RowDefinition Height="3"/> <RowDefinition Height="5" /> <RowDefinition Height="12"/> <RowDefinition Height="*"/> <RowDefinition Height="30"/> <RowDefinition Height="20"/> <RowDefinition Height="2"/> <RowDefinition Height="20"/> <RowDefinition Height="30" /> <RowDefinition Height="*"/> <RowDefinition Height="12"/> <RowDefinition Height="5"/> <RowDefinition Height="3"/> <RowDefinition Height="25"/> </Grid.RowDefinitions> <Border Grid.Column="6" Grid.ColumnSpan="3"> <TextBlock TextWrapping="Wrap" Text="45°" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Row="6" Grid.RowSpan="3" Margin="1.201,0,0,0"> <TextBlock TextWrapping="Wrap" Text="315°" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Border Grid.Row="14" Grid.ColumnSpan="3" Grid.Column="6"> <TextBlock TextWrapping="Wrap" Text="225°" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Row="6" Grid.Column="14" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text="135°" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Rectangle Grid.Column="7" Margin="0.062,0,0,-0.25" Grid.Row="2" Stroke="White" Fill="White" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="7" Grid.Row="12" Stroke="White" Fill="White" Margin="0.062,0,0,-0.001" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="2" Fill="White" Grid.Row="7" Stroke="White" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="12" Fill="White" Grid.Row="7" Stroke="White" Margin="0.25,0,0,0" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Border Grid.Column="6" Grid.Row="3" Grid.ColumnSpan="3" > <TextBlock TextWrapping="Wrap" Text="NE" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Column="3" Grid.Row="6" Grid.RowSpan="3" Margin="-3,-8,-10,-10"> <TextBlock TextWrapping="Wrap" Text="NW" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Border Grid.Column="11" Grid.Row="6" Grid.RowSpan="3" RenderTransformOrigin="0.5,0.5" Margin="-3.182,0.589,-1.818,-0.589"> <Border.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </Border.RenderTransform> <TextBlock TextWrapping="Wrap" Text="SE" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Margin="-6.513,-9.002,-8.487,-0.998" Grid.Column="6" Grid.Row="11" Grid.ColumnSpan="3" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text="SW" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.ColumnSpan="3" Grid.Column="6" Grid.Row="4"> <TextBlock TextWrapping="Wrap" Text="东
北" VerticalAlignment="Bottom" HorizontalAlignment="Center"/> </Border> <Border Grid.Column="4" Grid.Row="6" Grid.RowSpan="3" Height="30.098" Margin="0,1.902,0,0"> <TextBlock TextWrapping="Wrap" Text="西 北 " VerticalAlignment="Center" HorizontalAlignment="Right" RenderTransformOrigin="0.5,0.5"/> </Border> <Border Grid.ColumnSpan="3" Grid.Column="6" Grid.Row="10" Width="28.5"> <TextBlock TextWrapping="Wrap" Text="西
南" VerticalAlignment="Top" HorizontalAlignment="Center"/> </Border> <Border Grid.Column="10" Grid.Row="6" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text=" 东 南" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Center"/> </Border> </Grid> <Grid Width="300" Height="300" RenderTransformOrigin="0.5,0.5" Grid.RowSpan="3" Grid.ColumnSpan="3"> <Grid.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="67.5"/> <TranslateTransform/> </TransformGroup> </Grid.RenderTransform> <Grid.ColumnDefinitions> <!--外圈--> <ColumnDefinition Width="25"/> <ColumnDefinition Width="3"/> <ColumnDefinition Width="5"/> <ColumnDefinition Width="12"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="30"/> <ColumnDefinition Width="20"/> <ColumnDefinition Width="2"/> <ColumnDefinition Width="20"/> <ColumnDefinition Width="30"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="12"/> <ColumnDefinition Width="5"/> <ColumnDefinition Width="3"/> <ColumnDefinition Width="25"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="25"/> <RowDefinition Height="3"/> <RowDefinition Height="5" /> <RowDefinition Height="12"/> <RowDefinition Height="*"/> <RowDefinition Height="30"/> <RowDefinition Height="20"/> <RowDefinition Height="2"/> <RowDefinition Height="20"/> <RowDefinition Height="30" /> <RowDefinition Height="*"/> <RowDefinition Height="12"/> <RowDefinition Height="5"/> <RowDefinition Height="3"/> <RowDefinition Height="25"/> </Grid.RowDefinitions> <Border Grid.Column="6" Grid.ColumnSpan="3"> <TextBlock TextWrapping="Wrap" Text="67.5°" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Row="6" Grid.RowSpan="3" Margin="1.201,0,0,0"> <TextBlock TextWrapping="Wrap" Text="337.5°" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="-5,0"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Border Grid.Row="14" Grid.ColumnSpan="3" Grid.Column="6"> <TextBlock TextWrapping="Wrap" Text="247.5°" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Row="6" Grid.Column="14" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text="157.5°" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Center" Margin="-5,0" HorizontalAlignment="Center"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Rectangle Grid.Column="7" Margin="0.062,0,0,-0.25" Grid.Row="2" Stroke="White" Fill="White" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="7" Grid.Row="12" Stroke="White" Fill="White" Margin="0.062,0,0,-0.001" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="2" Fill="White" Grid.Row="7" Stroke="White" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Rectangle Grid.Column="12" Fill="White" Grid.Row="7" Stroke="White" Margin="0.25,0,0,0" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin"/> <Border Grid.Column="6" Grid.Row="3" Grid.ColumnSpan="3" > <TextBlock TextWrapping="Wrap" Text="ENE" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.Row="6" Margin="-3,-8,-10,-10" Grid.RowSpan="3" Grid.ColumnSpan="3" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" > <TextBlock TextWrapping="Wrap" Text="NNW" RenderTransformOrigin="0.5,0.5" d:LayoutOverrides="Height"> <TextBlock.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </TextBlock.RenderTransform> </TextBlock> </Border> <Border Margin="-6.075,4.789,1.315,5.21" Grid.Column="11" Grid.Row="6" Height="32" Grid.RowSpan="3" RenderTransformOrigin="0.5,0.5" Grid.ColumnSpan="3"> <Border.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="270"/> <TranslateTransform/> </TransformGroup> </Border.RenderTransform> <TextBlock TextWrapping="Wrap" Text="SSE" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Margin="-6.619,-12.909,-8.381,-2.091" Grid.Column="6" Grid.Row="11" Grid.ColumnSpan="3" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text="WSW" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <Border Grid.ColumnSpan="3" Grid.Column="6" Grid.Row="4"> <TextBlock TextWrapping="Wrap" Text="东
东
北" VerticalAlignment="Bottom" HorizontalAlignment="Center"/> </Border> <Border Grid.Column="4" Grid.Row="6" Grid.RowSpan="3" Height="30.098" Margin="0,1.902,0,0"> <TextBlock TextWrapping="Wrap" Text="北 西 北 " VerticalAlignment="Center" HorizontalAlignment="Right" RenderTransformOrigin="0.5,0.5"/> </Border> <Border Grid.ColumnSpan="3" Grid.Column="6" Grid.Row="10" Width="28.5"> <TextBlock TextWrapping="Wrap" Text="西
西
南" VerticalAlignment="Top" HorizontalAlignment="Center"/> </Border> <Border Grid.Column="10" Grid.Row="6" Grid.RowSpan="3"> <TextBlock TextWrapping="Wrap" Text=" 南 东 南" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Center"/> </Border> </Grid> <Path x:Name="PathFillColor" Fill="#FFBF3232" Stretch="Fill" Data=http://www.mamicode.com/"M0,200 L20,50 L55,50 L80,200" RenderTransformOrigin="0.5,0.74" Margin="-0.585,63.417,-0.639,-28.409" Grid.RowSpan="2" Grid.Column="1" d:LayoutOverrides="HorizontalAlignment" > <Path.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="{Binding ElementName=slider, Path=Value, Mode=OneWay}"/> <TranslateTransform/> </TransformGroup> </Path.RenderTransform> </Path> <Ellipse Fill="#FFFFDBDB" Stroke="#FFFFDBDB" Grid.Row="1" Grid.Column="1"/> </Grid> <Slider x:Name="slider" Value=http://www.mamicode.com/"100" Height="37.333" Margin="-51.945,112.948,0,0" Width="204.778" RenderTransformOrigin="0.5,0.5" Maximum="360" HorizontalAlignment="Left" VerticalAlignment="Top"> <Slider.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform Angle="90"/> <TranslateTransform/> </TransformGroup> </Slider.RenderTransform> </Slider> </Grid></Window>
WPF自定义仪表盘控件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。