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 8392261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:28:23+00:00 2026-06-09T19:28:23+00:00

I’m using a value converter which needs to get a list of types, which

  • 0

I’m using a value converter which needs to get a list of types, which is a property of the converter. If I would use list of double values, I could use the following syntax (which is working as expected):

Code

public class MyConverter : IValueConverter
{
    public List<double> MyList { get; set; }

    // ...
}

XAML

<Converter:MyConverter x:Key="MyConverter">
    <Converter:MyConverter.MyList>
        <System.Double>1</System.Double>
        <System.Double>2</System.Double>
    </Converter:MyConverter.MyList>
</Converter:MyConverter>

But if I try to use this approach with a list of types, an exception is thrown:

Object of type 'System.RuntimeType' cannot be converted to type 'System.Collections.Generic.List`1[System.Type]'

This is my converter and its usage:

Code

public class MyConverter : IValueConverter
{
    public List<Type> MyList { get; set; }

    // ...
}

XAML

<Converter:MyConverter x:Key="MyConverter">
    <Converter:MyConverter.MyList>
        <x:Type TypeName="MyType1" />
        <x:Type TypeName="MyType2" />
    </Converter:MyConverter.MyList>
</Converter:MyConverter>

I guess the XAML syntax is wrong but I can’t find the right syntax.

  • 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-06-09T19:28:25+00:00Added an answer on June 9, 2026 at 7:28 pm

    Seems like bug in the XAML designer. The given bellow code worked for me. I can build and run application. But In the designer R# hightlights two lines with System:Type and the designer crashes with next two errors per line:

    Error 1 Type ‘Type’ is not usable as an object element because it is
    not public or does not define a public parameterless constructor or a
    type converter.
    Error 2 The type ‘Type’ does not support direct
    content.
    So when I’ve tried that solution before (before giving previous solution) I thought I am doing smth wrong.
    But compiler still doesn’t give any error on build. Anyway here how it looks:

    <Window.Resources>
        <local:Holder x:Key="one">
            <local:Holder.Types>
                <System:Type>System:Int32</System:Type>
                <System:Type>System:Double</System:Type>
            </local:Holder.Types>
        </local:Holder>
    </Window.Resources>
    <Grid >
        <ListBox DataContext="{StaticResource one}" ItemsSource="{Binding Path=Types, Converter={StaticResource one}}" />
    </Grid>
    

    As far as you can see, the difference is in the declaration. You have to use System.Type rather than x:Type.

    and the code as a sample

    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Windows.Data;
    using System.Linq;
    
    namespace stackProjects
    {
        public class Holder : IValueConverter
        {
            public List<Type> Types { get; set; }
    
            public Holder()
            {
                Types=new List<Type>();
            }
    
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                return Types.Select(x => x.Name).ToList();
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }
    }
    

    As I was said, this happens because Type class is abstract.
    Hope it helps

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I would like to run a str_replace or preg_replace which looks for certain words
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.