开发者

How to pass data from child to parent view or between child views?

开发者 https://www.devze.com 2023-02-19 21:56 出处:网络
Hello I am currently migrating a C# WPF project to Silverlight and I stumbled on a problem also related to my lack of Silverlight knowledge:

Hello I am currently migrating a C# WPF project to Silverlight and I stumbled on a problem also related to my lack of Silverlight knowledge:

I have my MainPage.xaml which accepts several V开发者_如何学编程iews, for example

I want to pass a String from View1 to View2 programatically. Depending on the value that is passed from View1 , View2 will change. I don't know how to access/transmit values between views(or atleast a workaround - back to parent, and then to the other child? )

I have researched this topic for some time now, but I couldn't figure it out. If my question allready has an answer somewhere on forum || my question is poorly written || my question is stupid || other cases , I am deeply sorry - don't want to irritate/offend anyone.

Thank you.


Ok by view, you mean navigation pages.

Using navigation application, there is many ways to do that but I think the best way is using url parameters (just as html parameters) if your parameters are simple string values, then you can retrieve the value from code using

this.NavigationContext.QueryString["ProductId"];

for more details check here : http://msdn.microsoft.com/en-us/library/cc838245(VS.95).aspx#Y3804

If you need to pass complex types, use a public property in your view.

0

精彩评论

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