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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:14:29+00:00 2026-05-20T10:14:29+00:00

How flexible is DataBinding in WPF? I am new to WPF and would like

  • 0

How flexible is DataBinding in WPF? I
am new to WPF and would like to have a
clear idea. Can I Bind a string
variable with a Slider value? Does it
always have to be a control?

Is it at all possible to bind a string
value with a Slider control so that it
updates in real time? How far up the
Logical tree does the update travel or
do we have to reissue all the commands
to use this new value?

That was my hurried question earlier. I am posting a detailed problem.

What I am trying to do is, I have an application with multiple user-controls. These user controls are grid-views and contain controls (TextBox, Button) and sections of my application UI. I used this approach to split my main XAML file across multiple files and it works for me till now. Now, I have a Slider in one user control and want to bind a String variable in another user control. The string variable is read-only so there is no use for two-way binding.

I hope that makes my question clear. In my code, I am trying to update the variable zoomFactor in:

URLQuery.Append("&zoom=" + zoomFactor + "&size=600x500&format=jpg&sensor=false");

with a Slider control. For those who could spot that, yes, it is the Google Static Maps API and yes, I am trying to zoom into the map with a slider.

  • 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-20T10:14:30+00:00Added an answer on May 20, 2026 at 10:14 am

    You generally can do such things by using IValueConverter.

    When you create a proper converter you can specify to use it for the binding in the XAML.

    For the “real time” part, as far as you implement INotifyPropertyChanged properly in your DataContext object, modifying the variable will be reflected on the UI, applying all the value converter you decided.Lets’have an example using a slider as you said:

    <Window x:Class="Example.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:Example"
            Title="MainWindow" Height="350" Width="525"
            >
        <Window.Resources>
            <local:HMLConverter x:Key="hiloConverter"></local:HMLConverter>
        </Window.Resources>
        <Slider Value="{Binding MyValue, Converter={StaticResource hiloConverter}}"  Maximum="100" Minimum="0"/>
    </Window>
    

    I created a little converter, called HMLConverter, than maps a string variable to the value 0-50-100 for the respective “lo”,”med”,ang “hi” strings. The converter is declared as a static resource, and used in the binding. Converter code looks like:

    namespace Example
    {
        public class HMLConverter:IValueConverter
        {
            #region IValueConverter Members
    
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                string val = value.ToString();
                int ret = 0;
                switch (val.ToLower())
                {
                    case "hi":
                        ret = 100;
                        break;
                    case "lo":
                        ret = 0;
                        break;
                    case "med":
                        ret=50;
                        break;
                    default:
                        throw new NotSupportedException("Value " + val + " is not supported");
                }
                return ret;
    
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
    
            #endregion
        }
    }
    

    As you probably guess, I wrote it only in one direction, so the binding does not works in both way, but I’m sure you got the whole part.

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

Sidebar

Related Questions

I'm trying to create an flexible update query. I have now something like this:
I'm working on a flexible GUI application that can have ~12 varied layouts. These
I would like to provide a flexible authentication method for my RESTful webservice -
To make my code flexible I would like to find a way to get
Have you seen library for flexible working with terminal(Unix like)? I want to implement
I have created a flexible navigation bar in my app that will show custom
I know WPF is more complex an flexible so could be thought to do
We have an application that has to be flexible in how it displays it's
What is a Flexible Array, exactly? I can't find much on it.
I'd like a scaleable/flexible fullscreen inline image (no cropping) that will allow for content

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.