您的位置:首页 > 其它

Silverlight 主页与页面用户组件中方法的调用顺序

2011-10-28 15:39 417 查看
主页:UseNewUserControlPage.xaml

<navigation:Page x:Class="UseUserControl.UseNewUserControlPage"
           xmlns:newuc="clr-namespace:UseUserControl;assembly=UseUserControl"     
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="UseNewUserControlPage Page">
    <Grid x:Name="LayoutRoot">
        <newuc:NewConfrimBox Message="使用用户控件成功!"></newuc:NewConfrimBox>
    </Grid>
</navigation:Page>

 

后台代码:

public UseNewUserControlPage()
{
    InitializeComponent();
    test2();
}

private void test2()
{
 
}
组件后台代码:

public NewConfrimBox()
{
    InitializeComponent();
    test1();
}

private void test1()
{
 
}

 

由于在主页中使用了用户控件NewConfrimBox,所以,编译执行时,先执行 UseNewUserControlPage{}方法中的InitializeComponent();方法,然后执行组件中的NewConfrimBox()方法,执行test1()方 法,最后,组件的构造方法执行完成后,再来执行主页的test2()方法,完成主页构造方法的执行。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: