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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:29:54+00:00 2026-06-02T10:29:54+00:00

basically I used the posted Converter here and just changed the Datatype to be

  • 0

basically I used the posted Converter here and just changed the Datatype to be a generic. How do I use the generic Converter inside XAML?

public class ReverseListConverter<T> : MarkupExtension, IValueConverter
{
    public ReverseListConverter()
    {
    }

    private ObservableCollection<T> _reversedList;

    public override object ProvideValue(IServiceProvider serviceProvider)
    {
        return this;
    }

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        _reversedList = new ObservableCollection<T>();

        var data = (ObservableCollection<T>)value;

        for (var i = data.Count - 1; i >= 0; i--)
            _reversedList.Add(data[i]);

        data.CollectionChanged += DataCollectionChanged;

        return _reversedList;
    }

    void DataCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
    {
        var data = (ObservableCollection<T>)sender;

        _reversedList.Clear();
        for (var i = data.Count - 1; i >= 0; i--)
            _reversedList.Add(data[i]);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotSupportedException();
    }
}

Before the Converter was generic I just used

ItemsSource="{Binding Mails, Converter={tools:ReverseListConverter}}"

Is there a way to do this with a generic Converter in XAML?

  • 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-02T10:29:56+00:00Added an answer on June 2, 2026 at 10:29 am

    You can forget about making a generic converter a markup extension, you cannot simply create generic objects in XAML (there are some cases in which you can in .NET 4, don’t know if anything changed in 4.5).

    One way to create an instance would be using a helper class which contructs an instance for you (i wrote one in another question’s answer).

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

Sidebar

Related Questions

I used the pear system daemon class, that basically allows me to create a
I've used CCK to create a 'Travel Offer' content-type which basically just lists the
Is it possible to use a nested mysql_fetch_assoc Basically I used the first one
This is related to a question posted yesterday . class A { public: mutable
This is my class which is basically used for UnitForWork pattern i.e save everything
Here is some code that is used basically to show a table of listings
I've created an Engine which is basically used for all of our projects. Now
I have a page that will basically be used to concatenate a bunch of
Basically I have a table which is used to hold employee work wear details.
Basically I've written this program to check for strings. I've used socket method for

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.