WPF PATH 自适应问题

印度阿三学编程 2019-04-03 02:29:42
<Grid HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="5*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Canvas x:Name="gaugeCanvas" Margin="20,20,0,0" MouseDown="Canvas_MouseDown" Grid.Column="1">
<Path StrokeThickness="5" Width="300" Height="150" StrokeStartLineCap="Round">
<Path.Data>
<PathGeometry Figures="M 0,100 A 100,100 0 0 1 29.28932,29.28932"/>
</Path.Data>
<Path.Stroke>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0" Color="Green"/>
<GradientStop Offset="1.0" Color="Yellow"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Path.Stroke>
</Path>
<Path Stroke="LightGreen" StrokeThickness="5" Width="300" Height="130" StrokeStartLineCap="Round">
<Path.Data>
<PathGeometry Figures="M 0,100 A 100,100 0 0 1 29.28932,29.28932"/>
</Path.Data>
</Path>
<Path Stroke="Yellow" StrokeThickness="5" Width="300" Height="130">
<Path.Data>
<PathGeometry Figures="M 29.28932,29.28932 A 100,100 0 0 1 170.71068,29.28932" />
</Path.Data>
</Path>
<Path Stroke="Red" StrokeThickness="5" Width="300" Height="280" StrokeEndLineCap="Round">
<Path.Data>
<PathGeometry Figures="M 170.71068,29.28932 A 100,100 0 0 1 200,100" />
</Path.Data>
</Path>
<Path x:Name="indicatorPin" Fill="Orange">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="100,95" IsClosed="True">
<PathFigure.Segments>
<LineSegment Point="10,100"/>
<LineSegment Point="100,105"/>
</PathFigure.Segments>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
<TextBlock x:Name="currentValueTxtBlock" Foreground="White" FontSize="15" Canvas.Left="80" Canvas.Top="60" >速度</TextBlock>
</Canvas>
</Grid>


上面代码是一个userControl 但是不会自适应位置父控件的大小, 还有就是我想做成三个仪表盘 一起并列的效果 ,为什么放在grid中不会自适应?
...全文
777 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
引用 1 楼 岁月无情_1 的回复:
注意你用的Canvas
那父容器直接用grid吗
exception92 2019-04-04
  • 打赏
  • 举报
回复
还是先亲自动手练习练习基本属性
岁月无情_1 2019-04-03
  • 打赏
  • 举报
回复
<Grid HorizontalAlignment="Left">
岁月无情_1 2019-04-03
  • 打赏
  • 举报
回复
注意你用的Canvas

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧