根据您想要达到的目标,您可以在Button.Content属性中设置您的UIElement。
该Button.Content属性可以接受任何UIElement。
例如,你可以做到以下几点:
MainPage.xaml中
<Page ...>
<StackPanel ...>
<Button x:Name="myButton" Width="200" Height="200"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" >
<Button.Content>
<local:Page2 />
</Button.Content>
</Button>
</StackPanel>
</Page>
Page2.xaml
<Page...>
<Grid ...>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Rectangle Fill="Red" />
<Rectangle Fill="Yellow" Grid.Column="1"/>
<Rectangle Fill="Blue" Grid.Row="1"/>
<Button Content="Click Me" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center"/>
</Grid>
</Page>
或者从后面的代码:
MainPage.xaml中.cs
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
myButton.Content = new Page2();
}
}
[VisualBrush可能重复不再适用于Windows 8 Metro Apps?](http://stackoverflow.com/questions/9044066/visualbrush-no-longer-works-for-windows-8-metro-apps) – WiredPrairie