Silverlight 子窗口文件和导航项目

子窗口文件

在Silverlight3的项目中已经添加了ChildWindow 的文件,用来建立一个子窗口,一个模态窗口,用来相识更加丰富的信息交互。

image

默认我们会得到以下的Xaml内容,可以看到他的ns是controls,我们可以在其中包含你想要包含的XAML元素

<controls:ChildWindow x:Class="Sample.chapter12.ChildWindow1"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           Width="400" Height="300" 
           Title="ChildWindow1">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
        <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
    </Grid>
</controls:ChildWindow>

弹出子窗口的主窗口代码很简单

private void Button_Click(object sender, RoutedEventArgs e)
        {
            //实μ例y化ˉ子ó窗°口ú对?象ó
            MyChildWindow myWin = new MyChildWindow();
            //设è置?标ê题a和í内ú容Y
            myWin.Title = "这a是?我ò的?窗°口ú!?";
            //子窗口的内容
            myWin.Content = new TextBlock()
            {
                Text = @"大ó家ò好?,?这a是?Silverlight 3的?子ó窗°口ú界?面?!?",
                TextWrapping = TextWrapping.Wrap,
                Width = 380,
                FontSize = 23
            };
            //显?示?子ó窗°口ú
            myWin.Show();
        }
冯瑞涛
原文地址:https://www.cnblogs.com/finehappy/p/1669243.html