2024-04-23 18:18:36
浏览数 (2)
WPF-形状
代码语言:javascript
复制<Window x:Class="形状.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:形状"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Margin="66,-13,-66,13">The first row of a grid</TextBlock>
<Viewbox Grid.Row="2" HorizontalAlignment="Left">
<Canvas Width="200" Height="150">
<!--开始线帽 StrokeStartLineCap="Round"结束线帽 StrokeEndLineCap="Round" -->
<Line StrokeThickness="5" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Canvas.Left="150" Canvas.Top="20" Stroke="Red" X1="0" Y1="0" X2="10" Y2="100"></Line>
<Rectangle Fill="Yellow" Stroke="Blue" Canvas.Left="30" Canvas.Top="40" Height="60" Width="100" HorizontalAlignment="Left"> </Rectangle>
<Ellipse HorizontalAlignment="Left" Fill="Yellow" Stroke="Blue" Canvas.Left="10" Canvas.Top="50" Width="100" Height="50"></Ellipse>
<Polyline Stroke="Blue" StrokeDashArray="1 2" Points="5,5 15,50 50,70 100,1"></Polyline>
</Canvas>
</Viewbox>
</Grid>
</Window>