Wrox Programmer Forums
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
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 12th, 2011, 12:00 PM
Registered User
 
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?
 
Old August 12th, 2011, 04:52 PM
Registered User
 
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 ....





Similar Threads
Thread Thread Starter Forum Replies Last Post
populating a listbox with a field contains comma bjcountry Access 3 February 17th, 2016 05: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 11:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.