在MainWindow中,创建一个背景属性BrushTest,并将其绑定至界面
1 <Window x:Class="WpfApp8.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:WpfApp8" 7 mc:Ignorable="d" 8 Title="MainWindow" Height="450" Width="800" x:Name="TheMainWindow"> 9 <Grid> 10 <local:UserControl1 BackgroundTest="{Binding BrushTest}"/> 11 </Grid> 12 </Window>