1: <Window x:Class="VisualBrush.MainWindow"
2: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4: xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5: xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6: xmlns:local="clr-namespace:VisualBrush"
7: mc:Ignorable="d"
8: Title="MainWindow" Height="600" Width="800">
9: <Grid>
10: <Grid.ColumnDefinitions>
11: <ColumnDefinition>
12: </ColumnDefinition>
13: <ColumnDefinition >
14: </ColumnDefinition>
15: </Grid.ColumnDefinitions>
16: <Grid.RowDefinitions>
17: <RowDefinition></RowDefinition>
18: <RowDefinition></RowDefinition>
19: </Grid.RowDefinitions>
20: <Button x:Name="btn1" Grid.Column="0" >網智數位-軟體開發 , WPF - VisualBrush </Button>
21: <Rectangle Grid.Column="1" >
22: <Rectangle.Fill>
23: <VisualBrush Visual="{Binding ElementName=btn1}"></VisualBrush>
24: </Rectangle.Fill>
25: </Rectangle>
26:
27: <!--<Button x:Name="btn2" Grid.Row="1" Grid.Column="0" Background="Red">網智數位-軟體開發 , WPF - VisualBrush</Button>-->
28: <Image Source="gril.png" x:Name="img1" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stretch="Fill"></Image>
29: <Rectangle Grid.Column="1" Grid.Row="1" >
30: <Rectangle.Fill>
31: <VisualBrush Visual="{Binding ElementName=img1}"></VisualBrush>
32: </Rectangle.Fill>
33: </Rectangle>
34: </Grid>
35: </Window>