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

  • Home
  • SEARCH
  • 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 3497440
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:22:14+00:00 2026-05-18T12:22:14+00:00

I have to convrt a double to other using a converter and a parameter:

  • 0

I have to convrt a double to other using a converter and a parameter:

This is my XAML stub:

Converter={StaticResource ToOtherDoubleConverter}, ConverterParameter=-1/2

this is the converter:

[ValueConversion(typeof(double), typeof(double))]
public class DoubleToOtherDoubleConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, 
                          CultureInfo culture)
    {
        return (double)value * double.Parse(parameter.ToString());
    }

Now, this is useless to say that this is culture dependent, etc..

Is there a way to “hardcode” a double to be recognized as double?
Because the above variant could be written in different ways, by eg.:

ConverterParameter=-1/2
ConverterParameter=-0.5
ConverterParameter=-0,5
etc.

or also

double.Parse(parameter.ToString());
(double)parameter;

etc…

One more question:

How can I specify 1/3 in the floating format? something like

ConverterParameter=0.333333333333333333333333333333333333333333333333333333
  • 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-18T12:22:15+00:00Added an answer on May 18, 2026 at 12:22 pm

    try this

    public class DoubleToOtherDoubleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, 
            object parameter, CultureInfo culture)
        {
            var frac = ((string) parameter).Split('/');
            if (frac.Length == 2)
                return (double) value*double.Parse
                    (frac[0])/double.Parse(frac[1]);
            return (double) value* double.Parse(((string) parameter)
                .Replace(",", "."));
        }
    
        public object ConvertBack(object value, Type targetType, 
            object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some double values I want to convert to a string with this
Right now I have double numba = 5212.6312 String.Format({0:C}, Convert.ToInt32(numba) ) This will give
I have double values which I would like to convert to String values with
I have to convert a decimal number to octal and hexadecimal using bitwise operations.
I have this following code: if (userValueSom01 == realResult01) { //answer = correct //count
I have redesigned my Firebird based SQL database. As part of this process I
I have some customized string formats of double values. I need to convert these
I have this weird problem that a convert of a string on my machine
I have an place where i upload an SVG file using paperclip, and get
I'm currently writing some code where I have something along the lines of: double

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.