I'd be signalling to other controls with a command or something like that...
Jonas has a post on MVVM and command patterns etc (using the SL Extensions command implementation - http://www.codeplex.com/slextensions)... http://jonas.follesoe.no/YouCardRevisitedImplementingTheViewModelPattern.aspx Pretty good for loose coupling. Alternatively.. go full MVVM and bind the collapsed/expanded state and control using centralised (ViewModel) objects. For a quick result, go commands. From: [email protected] [mailto:[email protected]] On Behalf Of Stephen Price Sent: Thursday, 12 March 2009 6:15 PM To: [email protected] Subject: Re: VSM in ListboxItem DataTemplate I ended up walking right up the tree to the top level (via the Parent property on each element) Grid. Then discovered that the visualstatemanager was after a control, which a Grid is not. Jordan suggested (offlist) to use a user control inside my datatemplate. I've just got that working now (needs some prettying up but I can expand/collapse the control and the ListBoxItem resizes to suit!) now I need to figure out a way to signal to the control when another control is expanded so it can collapse. (Only want one at a time open). I think it would need to be the listboxItem in the case I has before but the Listboxitem isn't selected, all I had to go by was that a button inside the datatemplate had been clicked. cheers, Stephen On Thu, Mar 12, 2009 at 3:51 PM, .net noobie <[email protected]<mailto:[email protected]>> wrote: sounds like you are not getting the correct control...??? would it be the Listbox you need to pass in? is hard to know without seeing the xaml On Thu, Mar 12, 2009 at 3:02 PM, Stephen Price <[email protected]<mailto:[email protected]>> wrote: Hey all, I'm not sure if this is possible to do. Basically what I want is for my Listbox item to expand to show additional controls when a button on the listbox item is clicked. Think like an edit mode. When I edit the DataTemplate in Blend it shows the Basic vsm state but no option to add more states here. I manually put in some states into the xaml which Blend then shows and allows me to edit. Now how do I go about calling the state with VisualStateManager? If I click the button I can get the button that I clicked, grab the parent (which is a Grid) but it doesn't seem to be the right grid. maybe I have to go up a couple of levels? private void btnEdit_Click(object sender, RoutedEventArgs e) { VisualStateManager.GoToState(((Button) sender).Parent, "EditMode", true); } any ideas? Might have to do this in code rather than vsm. cheers, Stephen ________________________________ Support procedure: https://www.codify.com/lists/support List address: [email protected]<mailto:[email protected]> Subscribe: [email protected]<mailto:[email protected]> Unsubscribe: [email protected]<mailto:[email protected]> List FAQ: http://www.codify.com/lists/ozsilverlight Other lists you might want to join: http://www.codify.com/lists -- net noobie(tm) ========================= What is the 'Clean Feed'? No!!! Forced Australian Federal Government Internet Censorship http://nocleanfeed.com/ ________________________________ Support procedure: https://www.codify.com/lists/support List address: [email protected]<mailto:[email protected]> Subscribe: [email protected]<mailto:[email protected]> Unsubscribe: [email protected]<mailto:[email protected]> List FAQ: http://www.codify.com/lists/ozsilverlight Other lists you might want to join: http://www.codify.com/lists ________________________________ Support procedure: https://www.codify.com/lists/support List address: [email protected]<mailto:[email protected]> Subscribe: [email protected]<mailto:[email protected]> Unsubscribe: [email protected]<mailto:[email protected]> List FAQ: http://www.codify.com/lists/ozsilverlight Other lists you might want to join: http://www.codify.com/lists -------------------------------------------------------------------------------- Support procedure: https://www.codify.com/lists/support List address: [email protected] Subscribe: [email protected] Unsubscribe: [email protected] List FAQ: http://www.codify.com/lists/ozsilverlight Other lists you might want to join: http://www.codify.com/lists
