Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 4 and Visual Studio 2010 > BOOK: WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4
This is the forum to discuss the Wrox book WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4 by ; ISBN: 9780470477229
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 12th, 2011, 12:00 PM
Registered User
Points: 19, Level: 1
Points: 19, Level: 1 Points: 19, Level: 1 Points: 19, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Populating a ListBox using custom Item and Value fields using Resource values(p. 326)

I have a listbox and am populating it using a custom object with Items and Values similar to pre-WPF .NET dropdowns etc. but want to have the content values themselves in a static resource in XAML form. Took a first pass at the issue for a solution that populated the listbox from the .cs file using as a ref

http://social.msdn.microsoft.com/For...e-222d29792b5f

To populate the listbox from XAML, I was looking in the Wrox book here on p. 326 -- in the downloaded code for chapter 18 both Persons examples use a single instance ( albeit a very entertaining one ) not a multiple as in the shaded example "Classes in Code" ). Here's what I am trying at the moment: I have a SortabilityListBoxData class with fields SortabilityTypeID ( like value ) and SortabilityTypeName ( like displayabile name ) . In the XAML I have :

<Window.Resources>
<x:Array x:Key="m_sortabilityListBoxItems" Type="local:SortabilityListBoxData" >
<local:SortabilityListBoxData SortabilityTypeID="S" SortabilityTypeName="Sortable"/>
<local:SortabilityListBoxData SortabilityTypeID="N" SortabilityTypeName="Non-Sortable"/>
<local:SortabilityListBoxData SortabilityTypeID="O" SortabilityTypeName="Oversized"/>
</x:Array>
</Window.Resources> at the top of the xaml and then inside the cs

SortabilityListBoxData m_sortabilityListBoxItems[]; for the local variable.

Was thinking of adding

lbxSortability.ItemsSource = m_sortabilityListBoxItems; in the cs but it does not compute.

Do you have a plural Persons example that uses similar technique, say adding names like Paul Allen and Ozzie to the list?
Reply With Quote
  #2 (permalink)  
Old August 12th, 2011, 04:52 PM
Registered User
Points: 19, Level: 1
Points: 19, Level: 1 Points: 19, Level: 1 Points: 19, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Switching it now to :

<Window.Resources>
<x:List x:Key="m_sortabilityListBoxItems" Type="local:SortabilityListBoxData" >
<local:SortabilityListBoxData SortabilityTypeID="S" SortabilityTypeName="Sortable"/>
<local:SortabilityListBoxData SortabilityTypeID="N" SortabilityTypeName="Non-Sortable"/>
<local:SortabilityListBoxData SortabilityTypeID="O" SortabilityTypeName="Oversized"/>
</x:List>
</Window.Resources>

but it likes neither x:List nor the local classes declared -- SortabilityListBoxData.

Keeping on ....
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
populating a listbox with a field contains comma bjcountry Access 3 February 17th, 2016 04:07 PM
Populating Fields from a textbox teddyk ASP.NET 2.0 Basics 1 August 8th, 2008 06:25 AM
Populating a listbox dlamarche Excel VBA 3 November 1st, 2007 02:13 PM
Custom Resource Provider ssirfan29 ASP.NET 2.0 Basics 0 July 16th, 2007 08:04 AM
populating data into listbox adn datagrid madhava_ram Flash (all versions) 1 February 25th, 2005 10:46 PM



All times are GMT -4. The time now is 12:25 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.