In Focus
Kolkata Chapter Developer Day: May 25
C# Corner Delhi Chapter Meet, May-18, 2013 Official Recap
Istanbul Chapter May 2013 2nd Seminar Announced : Learn WinJS, Windows Store, MVC
Email :
Password :
Remember me?
Forgot password
Contribute
An Article
A Blog
A News
A Video
A Link
An Interview Question
Ask a Question
TECHNOLOGIES
.NET 4.5
Current Affairs
Learn .NET
SharePoint 2010
Web Development
.NET Assemblies
Databases & DBA
LightSwitch 2012
SharePoint 2013
Web Services in C#
ADO.NET in C#
Design & Architecture
LINQ
Silverlight with C#
Windows 8
AJAX in C#
Exception Handling C#
Mobile & Embedded
Smart Devices
Windows Azure
Android Programming
Graphics Design
Office 2013
SQL
Windows Controls C#
Articles C#
Hardware
OOP/OOD
SQL Server 2012
Windows Forms C#
ASP.NET Controls in C#
How do I
Operating Systems
Testing
Windows Phone 8
ASP.NET MVC with C#
HTML 5
PHP
TypeScript
Windows Server 2012
ASP.NET Programming
Internet & Web
Products
Visual C#
Windows Store Apps
C# Language
iPhone/iPad
Project Management
Visual Studio .NET
Workflow Foundation in C#
C# Tutorials
Java
Reports using C#
Visual Studio 2010
WPF
C, C++, MFC
Java and .NET
Robotics & Hardware
Visual Studio 2012
XAML
Career Advice
JavaScript, CSS
Security in .NET
WCF with C#
XML
Chapters
JQuery
Request a new Category
|
View All
ANSWERS
BLOGS
VIDEOS
INTERVIEWS
BOOKS
LINKS
NEWS
CHAPTERS
CAREER ADVICE
Making your Web Browser in C#
HTML 5 vs Native Apps
Secure Your Android Application from Hackers
Why to fear Object Oriented Programming approach
Check upcoming B'day in Asp.net
Happy Birthday Destin Joy
Compare strings using StringComparison.Ordin ...
Class vs Structure
Import Email from Gmail in ASP.NET
Get The Value From DataGridView To TextBox On c#
Blog
WPF: How to get ListboxItem from selected entity
Posted by
Nipun Tomar
in
Blogs
|
WPF
on
Nov 04, 2011
There will be some scenarios where we need to get the object of ListBoxItem which is hosting one of the the bound entity
Tweet
2994
0
0
Getting ListBoxItem from selected entity:
There will be some scenarios where we need to get the object of ListBoxItem which is hosting one of the the bound entity.Most probably it may be the SelectedItem.
Consider this scenario there is an business class called Employee and it's collection class is EmployeeCollection.We have binding which binds object of EmployeeCollection to a ListBox.If we access the SelectedItem property of ListBox it will return the Employee object.But the requirement is to get the ListBoxItem which hosts the selected entity on an event say SelectionChanged.
Code in VB.Net
:
Dim lbi As ListBoxItem = lstBox.ItemContainerGenerator.ContainerFromItem(lstBox.SelectedItem)
Code in C#:
ListBoxItem lbi = lstBox.ItemContainerGenerator.ContainerFromItem(lstBox.SelectedItem);
Note:
The above code can be used to get ListBoxItem of any object which is present in the collection.
This Feature is Sponsored By
DynamicPDF Merger is a developers dream for interacting with any existing PDF documents. Merge, append, split, form fill, flatten stamp and so much more.
WPF: Core Assemblies
What is WPF?
post comment
COMMENT USING
PREMIUM SPONSORS
iPhone, Android & Web Development Services
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
More Blogs from this Blogger
How to reset Dock in MAC OS
How to list all properties of an Entity
WPF XAML content with special character
WPF: Textblock Vs Label
Show/hide Solution and Advanced Build Configurations
Recycle IIS Application Pool
How To Disable All Triggers on a Database
How to get all dates between date range in sql query
Difference between URL and URI
Difference between RDL and RDLC formats
View All
SPONSORED BY
DynamicPDF ReportWriter Suite
PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Follow @twitterapi
Latest Blogs
Difference between IEnumerable and IEnumerator
Project Cost Estimation
Basic Aspects of Security and Control
Zoom Image in Different Way in ASP.NET
Gridview with checkbox with check all option
Download SAP Crystal Reports for Visual Studio 2010 - Its Free
Split Letter Of Word From String in SQL Server
Import Email from Gmail in ASP.NET
How to get thumbnail image from youtube embed code
Install Ajax control Toolkit in Visual Studio 2008
View All
Poll
Result
All Polls
What is the best product to build Mobile apps?
What is the best product to build Mobile apps
PhoneGap
Icenium
Xamarin Studio
KendoUI Mobile
JQueryMobile
Native iOS/Android
What is the best product to build Mobile apps
Options
Votes
%
PhoneGap
2
2.78
Icenium
0
0.00
Xamarin Studio
1
1.39
KendoUI Mobile
1
1.39
JQueryMobile
61
84.72
Native iOS/Android
7
9.72
Total
72
100%