2016-03-25供稿中心: 北大青鸟武汉中南软件学院
Window x:Class="WpfApplicationImage.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="400" Background="SteelBlue"
Grid Margin="10"
Grid.ColumnDefinitions
ColumnDefinition Width="160"
ColumnDefinition Width="*"
ColumnDefinition Width="160"
Grid.ColumnDefinitions
StackPanel x:Name="stackPanelLeft" Background="White"
Button x:Name="btn" Content="OK" Height="40"
StackPanel
Button Content=">>>" Grid.Column="1" Margin="5" Click="Button_Click"
StackPanel x:Name="stackPanelRight" Background="White"Grid.Column="2"
Grid
Window
private void Button_Click(object sender, RoutedEventArgs e)
{
VisualBrush vbrush = new VisualBrush(btn);
Rectangle rect = new Rectangle();
rect.Width = btn.Width;
rect.Height = btn.Height;
rect.Fill = vbrush;
rect.Opacity = 0.5; //为了表示是影像,我让不透明度为50%
this.stackPanelRight.Children.Add(rect);