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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:52:05+00:00 2026-05-18T21:52:05+00:00

I have a ListBox where I set the ItemsSource to a CollectionViewSource that is

  • 0

I have a ListBox where I set the ItemsSource to a CollectionViewSource that is populated from a WCF service. I use a value converter in the ListBox.ItemTemplate\DataTemplate to convert a property on the objects in the ItemsSource.

This all works as expected, but now I need to update the conversion process such that the converted value is still based on the individual object property values, except when a different property equals a specific value. And that value is set in the code behind of the xaml, this is field level variable set in the page constructor.

To do this I want pass the field level variable as the ValueConverter’s ConverterParameter. I’ve tried several ways mainly using the ideas from this this question except I always get an error parsing the xaml (and the app fails to load).

One fix might be add a property to the objects in the ItemsSource but I don’t really want to do that. Partially because that object is used in several projects so I don’t want to change i …. and because I want to see if the other method is even possible. Also I believe wpf has a MultiValue Converter (and maybe SL 4.0) but I’m on SL 3.0.

My guess is the issues I’ve had so far are because of the timing of the loading, binding and the parsing of the xaml.

So a few questions:

  • can this be done as I describe above?
  • if not what is the issue?
  • if not is there another way without add a property to the object?
  • 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-18T21:52:06+00:00Added an answer on May 18, 2026 at 9:52 pm

    Doesn’t sound to me like you want to be using the binding ConverterParameter in this case. If I’ve understood you correctly you have single value held at the UserControl level which you were wanting to assign to this parameter, therefore the parameter value for all instances would be the same.

    Instead the approach I would take is to add a property to the Converter code itself.

     public class ExampleConverter : IValueConverter
     {
    
        public int SpecialValue { get; set; }
    
        public override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                 if (value.Equals(SpecialValue))
                     return "Special!";
                 else
                     return value.ToString();
            }
            else
            {
                 return null;
            }
        }
    
        public override object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    Now you’d have this converter added to the UserControl resources:-

    <UserControl.Resources>
       <local:ExampleConverter x:Key="conv" SpecialValue="-1" />
    </UserControl.Resources>
    

    If you need to modify the value in the UserControl code you would use:-

    ((ExampleConverter)Resources["conv"]).SpecialValue = someOtherVariable;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Listbox that I binds to a resource (sort) CollectionViewSource in my
I have a Listbox with an itemssource set to an ObservableCollection of DataRow. Let's
I have a little issue. I have a a ListBox that is bound to
I don't know what I'm doing wrong here. I have a ListBox whose DataContext
I have a ListBox bound to an ObservableCollection. The items in the collection each
I'm developing a Windows Phome application. I have the following ListBox on a page:
I have the Xaml which should basically bind a set of ContextualButtons for a
I have several ListBoxes and have set up the group style to make the
Hello, I have 3 Buttons add,delete,open as RelayCommands in my DocumentViewModel . Below you
I have class Employee which is something like this. class Emp { int EmpID;

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.