参照自:https://www.cnblogs.com/jixin/p/4730170.html
https://blog.csdn.net/u012408847/article/details/86482399
截图功能将会把红色方块区域内的内容截取下来,保存在img文件夹中。
window1.xaml
<Window x:Class="_1_5GraphicsWpf.Window1"
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:_1_5GraphicsWpf"
xmlns:cvr="clr-namespace:_1_5GraphicsWpf.ControlValidationRule"
mc:Ignorable="d"
Title="Window1" Height="450" Width="800">
<Grid>
<DockPanel Background="AliceBlue">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"></ColumnDefinition>
<ColumnDefinition Width="13*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Canvas Grid.Column="1" x:Name="myCanvas" DockPanel.Dock="Right" Background="LightGray"
PreviewMouseLeftButtonDown="Canvas_PreviewMouseLeftButtonDown" PreviewMouseMove="Canvas_PreviewMouseMove"
MouseLeftButtonUp="MyCanvas_MouseLeftButtonUp"
></Canvas>
<Grid DockPanel.Dock="Left" x:Name="LeftDockPanel">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="3*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30px"></RowDefinition>
<RowDefinition Height="30px"></RowDefinition>
<RowDefinition Height="30px"></RowDefinition>
<RowDefinition Height="30px"></RowDefinition>
<RowDefinition Height="30px"></RowDefinition>
<RowDefinition Height="30px"></RowDefinition>
<RowDefinition Height="30px"></RowDefinition>
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0">颜色œ˜œ˜œ˜œ˜</Label>
<ComboBox x:Name="ComboColor" Grid.Row="0" Grid.Column="1" Margin="6 3"
SelectedValuePath="{Binding Path=ID}" SelectedIndex="{Binding Path=Combo_ColorIndex}" >
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=PColor}"></TextBlock>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<