Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3427956
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:54:03+00:00 2026-05-18T06:54:03+00:00

I was wondering how I would easily be able to add a list of

  • 0

I was wondering how I would easily be able to add a list of doubles to a list within my FoodItem class.

My XAML:

<src:FoodItemCollection x:Key="Drinks">
            <src:FoodItem Name="Fountain" ImagePath="Resources\drinks_fountain.png" Price="2.50,2.00,1.50"></src:FoodItem>
            <src:FoodItem Name="Popcan" ImagePath="Resources\drinks_popcan.png" Price="1.50"></src:FoodItem>
            <src:FoodItem Name="Bottle" ImagePath="Resources\drinks_bottle.png" Price="2.00"></src:FoodItem>
            <src:FoodItem Name="Slushy" ImagePath="Resources\drinks_slushy.png" Price="3.50,3.00,2.50"></src:FoodItem>
        </src:FoodItemCollection>

My FoodItem class has a method called Price:

public class FoodItem
{
...
List<double> prices = new List<double>();
...

public List<double> Price
        {
            get { return prices; }
            set
            {
                prices = value;
            }
        }
...
}

Unfortunately, the way I am inputting the list of prices in my XAML file is giving me an error. But it is compiling.

The error I am getting is :

A first chance exception of type ‘System.Windows.Markup.XamlParseException’ occurred in PresentationFramework.dll

Additional information: ‘List`1’ type does not have a public TypeConverter class. Error at Line 31 Position 85

Line 31 is the code at the top.

Thanks for all the help 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:54:03+00:00Added an answer on May 18, 2026 at 6:54 am

    You can’t add items to a list or array (as far as I know) with the XAML syntax you are using in your prices.

    Price=”3.50,3.00,2.50″

    When it is trying to convert (and assign) the multiple prices string into the List at runtime, it throws the exception.

    This little example shows you how to add values to an array in Xaml:

    <Window x:Class="XamlTest.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:sys="clr-namespace:System;assembly:mscorlib"
            xmlns:src="clr-namespace:MyTestXaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <Grid.Resources>
                <src:FoodItem x:Key="Drinks">
                    <src:FoodItem.Prices>
                        <sys:Double>3.5</sys:Double>
                        <sys:Double>3.0</sys:Double>
                        <sys:Double>2.5</sys:Double>
                    </src:FoodItem.Prices>
                </src:FoodItem>
            </Grid.Resources>
            <ListBox DataContext="{StaticResource Drinks}"
                     ItemsSource={Binding Prices}/>
        </Grid>
    </Window>
    

    If you want to put FoodItem into a FoodItemCollection, follow the same pattern, which you are already doing. You just needed to take it a step farther with your prices.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering how would you store a list of categories and sub categories
I was wondering would I still need to use a basic game loop for
I'm wondering what would be best to do. Right now I have running a
I am wondering what would happen if I tried to read files in Java
Hey im just wondering what would be the best collection to use when creating
So I am wondering what would cause it so that all events for the
i was wondering what would be the best way to code a browser plugin
I was just wondering which would be cheaper, using a try catch block for
I am wondering how would I deal with a call to a function when
I am wondering what would be the best approach to store, for let's say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.