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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:43:19+00:00 2026-05-25T21:43:19+00:00

<Setter Property=IsChecked> <Setter.Value> <MultiBinding> <!– Get value for property –> <Binding Path=IsPressed RelativeSource={RelativeSource Self}

  • 0
<Setter Property="IsChecked">
    <Setter.Value>
        <MultiBinding>
            <!-- Get value for property -->
            <Binding Path="IsPressed" RelativeSource="{RelativeSource Self}" Mode="OneWay"/>
            <!-- Set value to ViewModel's property -->
            <Binding Path="Shift" Mode="OneWayToSource"/>
        </MultiBinding>
    </Setter.Value>
</Setter>

I need to use 2 bindings for property: one to get value for property and one to set value to ViewModel’s property.
How I can realize this scenario?

  • 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-25T21:43:20+00:00Added an answer on May 25, 2026 at 9:43 pm

    You can create a couple of attached properties. One will be the target of your binding, and second will contain binding for your proxy. Example:

    Then in ProxySource OnChange implementation you will get TextBox as UIElement, there you can read value from ProxySource and write it to ProxyTarget.
    This is not a very clean aproach, but it should work.
    If you can’t get it working, I can write a complete sample later.
    Ok, I’ve implemented everything, here’s complete source:

    public class ViewModel : ViewModelBase
    {
        string sourceText;
        public string SourceText
        {
            get { return sourceText; }
            set
            {
                if (sourceText == value) return;
                sourceText = value;
                System.Diagnostics.Debug.WriteLine("SourceText:" + value);
                RaisePropertyChanged("SourceText");
            }
        }
    
        string targetText;
        public string TargetText
        {
            get { return targetText; }
            set
            {
                if (targetText == value) return;
                targetText = value;
                System.Diagnostics.Debug.WriteLine("TargetText:" + value);
                RaisePropertyChanged("TargetText");
            }
        }
    }
    
    public static class AttachedPropertiesHost
    {
        public static object GetProxySource(DependencyObject obj)
        {
            return obj.GetValue(ProxySourceProperty);
        }
    
        public static void SetProxySource(DependencyObject obj, object value)
        {
            obj.SetValue(ProxySourceProperty, value);
        }
    
        public static readonly DependencyProperty ProxySourceProperty =
                DependencyProperty.RegisterAttached(
                    "ProxySource", typeof(object), typeof(AttachedPropertiesHost),
                    new UIPropertyMetadata(null, ProxySourcePropertyPropertyChanged)
                );
    
        private static void ProxySourcePropertyPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            dependencyObject.Dispatcher.BeginInvoke(
                    new { Dp = dependencyObject, NewValue = e.NewValue },
                    args => SetProxyTarget(args.Dp, args.NewValue)
                );
        }
    
        public static object GetProxyTarget(DependencyObject obj)
        {
            return obj.GetValue(ProxyTargetProperty);
        }
    
        public static void SetProxyTarget(DependencyObject obj, object value)
        {
            obj.SetValue(ProxyTargetProperty, value);
        }
    
        public static readonly DependencyProperty ProxyTargetProperty =
                DependencyProperty.RegisterAttached("ProxyTarget", typeof(object), typeof(AttachedPropertiesHost));
        }
    
    <TextBox Text="{Binding SourceText, UpdateSourceTrigger=PropertyChanged}" 
                 WpfDataGridLayout:AttachedPropertiesHost.ProxySource="{Binding RelativeSource={RelativeSource Self}, Path=Text, UpdateSourceTrigger=PropertyChanged}"
                 WpfDataGridLayout:AttachedPropertiesHost.ProxyTarget="{Binding TargetText, Mode=OneWayToSource}"
                 />
    

    And the output from console while editing textbox:
    SourceText:f
    TargetText:f
    SourceText:fh
    TargetText:fh
    SourceText:fhh
    TargetText:fhh

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

Sidebar

Related Questions

Debugging a binding when it is like this IsChecked={Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}, Mode=TwoWay,
If have this in the setter of a property: decimal? temp = value as
<Style x:Key=FavouriteMenuItemStyle TargetType={x:Type MenuItem} BasedOn={StaticResource BasicFavouriteItemStyle}> <Setter Property=Width Value=Auto/> <Setter Property=Template> <Setter.Value> <ControlTemplate TargetType={x:Type
I've tried: <UniformGrid DockPanel.Dock=Top Columns=2 Rows=1> <UniformGrid.Resources> <Style TargetType=RadioButton> <Setter Property=Template> <Setter.Value> <ControlTemplate TargetType=RadioButton>
Here is my XAML: <Setter Property=Template> <Setter.Value> <ControlTemplate> <Image x:Name=Expander_Normal Source=/Images/arrow-e.tiff Width=13 Height=13 />
I have a simple setter method for a property and null is not appropriate
Is there any way to serialize a property with an internal setter in C#?
I'm extending Exception to implement a setter on the Message property. And this works
In my ActionScript3 class, can I have a property with a getter and setter?
i have a simple checkbox <CheckBox IsChecked={Binding ForceInheritance}/> In Code i have a class

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.