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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:50:01+00:00 2026-05-28T00:50:01+00:00

I want to be able to convert an integer to a string using a

  • 0

I want to be able to convert an integer to a string using a lookup table (list) in my code.
Both the integer and the list is passed on from a COM and bound to observables in my code.

<ListView Name="IdList" MaxWidth="310" Height="190" Margin="5" SelectionMode="Single" 
          ItemsSource="{Binding Path=TypeItem.Ids}">'

<GridViewColumn Width="Auto" 
                DisplayMemberBinding="{Binding Path=ShipType, 
                    Converter={StaticResource ShipTypeConverter}, 
                    ConverterParameter={x:Static vm:ConfigStaticItem.alternatives_shiptype}}"/>`

I have tried using multibinding, but only got DependencyProperty.UnsetValue for the list value

<GridViewColumn Width="Auto">
  <GridViewColumnHeader Content="ShipType"/>
  <GridViewColumn.DisplayMemberBinding >
    <MultiBinding Converter="{StaticResource ShipTypeMultiConverter}">
      <Binding Path="ShipType"/>
      <Binding Path="ConfigStaticItem.alternatives_shiptype"/>
    </MultiBinding>
  </GridViewColumn.DisplayMemberBinding>
</GridViewColumn>

[ValueConversion(typeof(byte), typeof(string))]
public class ShipTypeMultiConverter : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        try
        {
            byte state = (byte)values[0];
            List<StaticId> list = (List<StaticId>)values[1];
            return state.ToString();
        }

        catch
        {
            return "";
        }
    }

Also tried using templates, but I think I got lost in the XAML :).

vm is a reference to my ViewModel
the TypeItem.Ids is defined as List, where Static is an observable class containing amongst other stuff the ShipType value

Does anybody have any suggestions how to solve this?enter code here

  • 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-28T00:50:02+00:00Added an answer on May 28, 2026 at 12:50 am

    And the solution was:

    1. Adding a source to my resource dictionary

      <CollectionViewSource
          x:Key="ShipTypeSource"
          Source="{Binding ConfigStaticItem.alternatives_shiptype}"
          />
      
    2. Using a standard binding with the static resource as converter parameter

      <GridViewColumn
          Width="Auto"
          Header="Ship Type"
          DisplayMemberBinding="{Binding Path=ShipType, Converter={StaticResource ShipTypeConverter},
          ConverterParameter={StaticResource ShipTypeSource}}"
          />
      
    3. And using a singlevalue converter

      [ValueConversion(typeof(byte), typeof(string))]
      public class ShipTypeConverter : IValueConverter
      {
          public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
          {
              try
              {
                  Alternatives ShipTypes = (Alternatives)((parameter as CollectionViewSource).Source);
                  byte Type = (byte)value;
                  foreach (var key in ShipTypes)
                  {
                      if ((uint)Type == key.Key)
                      {
                          return key.Value;
                      }
                  }
                  return ""; // Ship type is undefined
              }
      
              catch
              {
                  return "";
              }
          }
      
          public object ConvertBack(object value, Type targetType,
              object parameter, CultureInfo culture)
          {
              return null;
          }
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to convert a List<T> into a specific JSON table-like
I have a list of integers and I want to be able to convert
Using Python 2.6 I want to be able to convert numbers such as 00000,
I want to be able to convert a string number such as 1,427.76 to
I am using GMP, and I want to be able to quickly convert an
I want to be able to convert big ints into their full string derivatives.
I want to be able to convert the following string format to Datetime. '21-04-2010
I want to be able to convert between the Gregorian and Julian calendars (note:
I'm using LaTeX and BibTeX for an article, and I want to able to
I want to be able to generate PDF output from my (native) C++ Windows

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.