1、扇形自定义控件CircularSectorControl

窗体布局xaml:

    <Grid x:Name="mainGrid" MouseEnter="MainGrid_MouseEnter" MouseLeave="MainGrid_MouseLeave">
        <Path x:Name="sectorPath" Data="M 200,200 0,200 A 200,200 0 0 1 58.6,58.6z" Fill="{Binding ElementName=sector, Path=BackgroundColor}"></Path>
        <Image Source="{Binding ElementName=sector, Path=DisplayImage}" Stretch="Fill" Width="35" Height="35" HorizontalAlign
实现效果如下:思路:扇形自定义控件组合成半圆型菜单,再通过clip实现菜单的展开和折叠。步骤:1、扇形自定义控件CircularSectorControl窗体布局xaml: &lt;Grid x:Name="mainGrid" MouseEnter="MainGrid_MouseEnter" MouseLeave="MainGrid_MouseLeave"&gt; &lt;Path x:Name="sectorPath" Data="M 200,200 0
使用 WPF 窗口作为弹出层 前几天领导让我在 WPF 的查询页面添加一个弹出层,防止用户查询大量数据时疯狂点击查询按钮或其他地方,我想了想最后决定用一个新的窗口做弹出层, WPF 上面的控件都是使用 “Material Design In XAML Toolkit” 做的。 我自己做的弹出层非常简单,就是一个窗体上放了一个会转的半圆和一个Label控件 但是运行时发现不太正常,点击主窗口时,弹出层会被主窗口覆盖在下面 然后设置了属性 //loadingWindow是弹出窗口的名称 loadingWindow.Ow
正三角形(左):<Path Data="M40,0 L0,30 40,60 z" Stretch="Uniform"/> 正三角形(上):<Path Data="M0,40 L30,0 60,40 z" Stretch="Uniform"/> 正三角形(右):<Path Data="M0,0 L40,30 0,60 z" Stretch="Unif...
<Window x:Class="DrawArrow.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="550" Width="625"> <Grid x:Name="mainGrid" MouseEnter="MainGrid_MouseEnter" MouseLeave="MainGrid_MouseLeave">
WPF 中可以通过Path绘制椭圆弧线。 &lt;Canvas Margin="100,100,0,0"&gt; &lt;!--颜色 线粗 整个路径的最大显示宽度 整个路径的最大显示高度 轮廓间隔 轮廓形状 相对Canvas左边界的距离 相对Canvas上边界的距离--&gt; &lt;Path Stroke="Green" StrokeThickness="1...
<Button Cursor="Hand" Name="button1" Opacity="1" Click="button1_Click" Background="Red" Margin="298,119,298,242"> <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> ```xml <Path Stroke="Gray" StrokeThickness="10" Data="M 100,50 A 50,50 1 1 99.99,50" /> <Path Stroke="Blue" StrokeThickness="10" Data="M 100,50 A 50,50 1 1 99.99,50" StrokeStartLineCap="Round" StrokeEndLineCap="Round"> <Path.Data> <PathGeometry> <PathFigure StartPoint="100,"> <ArcSegment Point="100," Size="50,50" SweepDirection="Clockwise" /> </PathFigure> </PathGeometry> </Path.Data> <Path.Triggers> <EventTrigger RoutedEvent="Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[].(PathFigure.StartPoint).X" From="100" To="" Duration="::5" RepeatBehavior="Forever" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Path.Triggers> </Path> </Grid> 这个代码使用了两个 `Path` 元素,一个用于绘制灰色的 半圆形 ,另一个用于绘制蓝色的进度条。蓝色的进度条使用了 `PathGeometry` 和 `ArcSegment` 来绘制一个 半圆形 的弧线,并通过 `DoubleAnimation` 实现了进度条的动画效果。