这是我的 ChildWindow xaml 代码:
1 <Grid x:Name="LayoutRoot">
2 <Grid x:Name="teste">
3 <Grid.ColumnDefinitions>
4 <ColumnDefinition Width="*"/>
5 <ColumnDefinition Width="*"/>
6 </Grid.ColumnDefinitions>
7 <Grid.RowDefinitions>
8 <RowDefinition />
9 <RowDefinition Height="Auto" />
10 </Grid.RowDefinitions>
11 <local:UserControl1 Grid.Row="0" Grid.ColumnSpan="2"/>
12 </Grid>
13 </Grid>
这是我的 UserControl1 xaml 代码:
1 <Grid x:Name="LayoutRoot" Background="#FFA34444">
2 <Button Click="Child_Close" Content="Cancel">
3 </Grid>
这是我的用户控件 C#:
private void Child_Close(object sender, System.Windows.RoutedEventArgs e)
{
ChildWindow cw = (ChildWindow)this.Parent;
cw.Close();
}
尝试这种方法是行不通的。任何想法?
Tks 乔西