WPF: How hard could it be to get a SelectedItemTemplate?

Posted by: Rick Strahls WebLog, on 24 May 2007 | View original

Here's a fun one to do in WPF. Say you have a ListBox or ListView that is databound and you want to get at the content of the data template used for binding of the items in the list. In my case I want to trigger an animation when the item is selected to indicate the change. It's quite easy to get a selected item from a list box:  // *** Bound item - ie. an XmlNode/XmlElement XmlElement item = this.lstPhotos.SelectedItem as XmlElement; if (item == null)     return; This assumes...

Advertisement
The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.

News Categories

.NET | ADO.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Community Server | dasBlog | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD