C# 将参数传递给Silverlight用户控件

C# 将参数传递给Silverlight用户控件,c#,silverlight,user-controls,navigation,C#,Silverlight,User Controls,Navigation,在Silverlight用户控件的代码隐藏文件中有一个方法,我应该向其传递一个字符串参数。我正在尝试以下方法,但得到一个错误System.Collections.Generic.KeyNotFoundException Message=在字典中找不到密钥。 我这样称呼这个页面: string idstr = xxxx; // my value this.NavigationService.Navigate(new Syste

在Silverlight用户控件的代码隐藏文件中有一个方法,我应该向其传递一个字符串参数。我正在尝试以下方法,但得到一个错误System.Collections.Generic.KeyNotFoundException Message=在字典中找不到密钥。

我这样称呼这个页面:

        string idstr = xxxx; // my value
        this.NavigationService.Navigate(new
                    System.Uri("/MyPage?id=" + idstr, System.UriKind.Relative));
上面的Uri字符串按预期显示在浏览器中(如果我不想在UserControls的初始化中解析它)

MyUserControl在MyPage XAML(我导航到的位置)中调用:



我做错了什么?我是否朝着正确的方向前进?

使用initParams怎么样

        string idstr = xxxx; // my value
        this.NavigationService.Navigate(new
                    System.Uri("/MyPage?id=" + idstr, System.UriKind.Relative));
<uc:MyUserControl />