Listbox / Button Text update
-
Hey all, I am working on some code for Silverlight / windows phone: I have 2 Xaml pages , Main and Second page: Main page , I have a button. With default text. " button" I have an OnHold event, that navigates to Second.xaml page. On Second.xaml page is a ListBox. With lets say 3 ListBoxItems. item1, item2 and item3. Here's where I am lost. I want to have my selected item() 1 2 or 3, do 2 things: 1. Update the text in the button on the MainPage.xaml. The text says "item1" or whateveritem I selected. 2. The selected item in the listbox also selects an object in a folder. Call this folder resources. and the objects lets say are text or png files or whatever...just something I created outside of the IDE. I wil worry about any OnClick functions or what to do with the objects in the folder later. Its the selection / update upon multiple pages that gets me right now.
-
Hey all, I am working on some code for Silverlight / windows phone: I have 2 Xaml pages , Main and Second page: Main page , I have a button. With default text. " button" I have an OnHold event, that navigates to Second.xaml page. On Second.xaml page is a ListBox. With lets say 3 ListBoxItems. item1, item2 and item3. Here's where I am lost. I want to have my selected item() 1 2 or 3, do 2 things: 1. Update the text in the button on the MainPage.xaml. The text says "item1" or whateveritem I selected. 2. The selected item in the listbox also selects an object in a folder. Call this folder resources. and the objects lets say are text or png files or whatever...just something I created outside of the IDE. I wil worry about any OnClick functions or what to do with the objects in the folder later. Its the selection / update upon multiple pages that gets me right now.
You mean auto select a file / folder in an external Windows Explorer window? You can just do something like: System.Diagnostics.Process.Start("explorer.exe", avi.Path); and it will auto-select the folder / file in avi.Path for you. Does Main have a reference to Second? or does Second have a reference to Main? Really, in proper MVVM, they shouldn't know about each other, so you should use something like a messenger service to communicate between views.
-
You mean auto select a file / folder in an external Windows Explorer window? You can just do something like: System.Diagnostics.Process.Start("explorer.exe", avi.Path); and it will auto-select the folder / file in avi.Path for you. Does Main have a reference to Second? or does Second have a reference to Main? Really, in proper MVVM, they shouldn't know about each other, so you should use something like a messenger service to communicate between views.
Well actually I think simpler than that? this is strictly going to be a windows phone application using a couple xaml pages. No windows.exe or anything like that. so no mesenger service either as navigating from one xaml to another in a windows phone app is normal and accepted.
-
Well actually I think simpler than that? this is strictly going to be a windows phone application using a couple xaml pages. No windows.exe or anything like that. so no mesenger service either as navigating from one xaml to another in a windows phone app is normal and accepted.
Do you have a reference to the other page? You could just subscribe to a simple event.
-
Do you have a reference to the other page? You could just subscribe to a simple event.
A reference? Well the only reference I have in a snece is the button OnHold event navigationg to the second page.
-
A reference? Well the only reference I have in a snece is the button OnHold event navigationg to the second page.
Hmm.. well, I'll have to hand you off to the Silverlight guys then. If you don't have a reference to the page and don't want to use messenger (which is really simple IMO), then I'd think you'd need a global static class that exposes an event or holds the references there. There might be something to handle that in Silverlight that I'm not aware of. In WPF, I'd certainly use messenger to communicate between views.