wpf 自定义面板布局
这里实现了一个横向的简易版 StackPanel // 1. 计算需要的尺寸 protected override Size MeasureOverride(Size availableSize) { var resultSize = new Size(); // 需要的总尺寸 var currentLineSize = new Size(); /…
2025-6-04 20:34
|
92
|
|
131 字
|
6 分钟
.net 动态构建 LINQ
var item = Expression.Parameter(typeof(Product), "item"); var name = Expression.Property(item, nameof(Product.Name)); var price = Expression.Property(item, nameof(Pr…
2025-6-04 20:21
|
57
|
|
38 字
|
2 分钟
wpf 启动项目中加入测试后
编译会提示项目中存在多个 Main 方法(即多个入口点) 编译 csproj 文件,加入如下内容 <PropertyGroup> <!-- 指定项目中的启动 App 类的完整名称 --> <StartupObject>WpfDemoApp.App</StartupObject> </Proper…
2025-6-04 20:12
|
65
|
|
42 字
|
1 分钟内
wpf 跟随路径代码方式
使用 StrokeDashOffsetProperty 调整实线填充效果 调用 PathGeometry.GetPointAtFractionLength 获得当前坐标点及方向 xaml <Grid Loaded="FrameworkElement_OnLoaded"> <Grid.Resources> …
2025-6-04 11:51
|
35
|
|
181 字
|
8 分钟
wpf 跟随路径动画方式
xaml <Canvas> <Canvas.Resources> <!-- 1. 定义移动的路径, 这里画了一个五角形 --> <PathGeometry x:Key="MovePathGeometry" Figures="M 175,30 L 213.88,123.63 L …
2025-6-03 20:55
|
47
|
|
47 字
|
3 分钟
wpf 网格背景
原来使用控件,但是鼠标事件会受到子控件影响,现在改成装饰器 xaml <ctrlHelpers:GridLineDecorator> <Canvas /> </ctrlHelpers:GridLineDecorator> cs public class GridLineDecorator : Decorator …
2025-6-03 20:26
|
46
|
|
343 字
|
16 分钟
wpf 波浪进度条
画了个正弦波图形 这里使用其它方式实现 https://www.bilibili.com/video/BV1GL411H746 ,其它 css 中也看过这个思路 xaml <Border BorderBrush="#4d4CAF50" BorderThickness="1" ClipToBounds=&…
2025-6-03 12:36
|
48
|
|
142 字
|
6 分钟
wpf path data
<Grid TextElement.FontWeight="ExtraBold"> <Grid.Resources> <Style TargetType="Path"> <Setter Property="Stroke" Value="R…
2025-5-30 18:30
|
53
|
|
119 字
|
5 分钟
wpf DockBar
xaml <Window ouseMove="DockBarWindow_OnMouseMove"> <Grid> <StackPanel x:Name="DockBarStackPanel" Margin="12" HorizontalAlignment=&…
2025-5-30 0:57
|
59
|
|
70 字
|
4 分钟
wpf 鼠标动画
xaml <Grid x:Name="RootGrid" Background="#000123" /> cs private readonly DispatcherTimer time = new(); // 创建动画 private Storyboard CreateStoryBoard(Sh…
2025-5-30 0:10
|
72
|
|
88 字
|
5 分钟