开发者

Hyperlink Navigationuri with parameter wpf

I want to set navigateURI to the dynamically created hyperlink. I am using the following code but it is not navigation to the page if i pass parameter. showing the following error.

Code:

   Hyperlink hlProduct = new Hyperlink(new InlineUIContainer(img));
   hlProduct.NavigateUri = new Uri("Player.xaml?id=109", UriKind.Relative);

public partial class Player : Page
{        
    public Player(string id)
    {
        InitializeComponent();
     }
} 

Error:

Cannot create object of type 'ProductPlayer'. CreateInstance failed, which can be caused by not having a public defaul开发者_开发知识库t constructor for 'ProductPlayer'. Error in markup file 'Player.xaml' Line 1 Position 7.

Geetha.


Remove the id parameter from Player class, should be as below:

public Player() { InitializeComponent(); }

To extract the parameters use NavigationService.CurrentSource, which return uri object. Parse this object to get id value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜