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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:03:37+00:00 2026-06-10T17:03:37+00:00

Time for my first question :) I have the following: public class BuilderViewModel :

  • 0

Time for my first question 🙂

I have the following:

public class BuilderViewModel : INotifyPropertyChanged
{
    #region Implementation of INotifyPropertyChanged

    public event PropertyChangedEventHandler PropertyChanged;

    #endregion

    private double _contentScale = 1.0;

    public double ContentScale
    {
        get { return _contentScale; }
        set
        {
            _contentScale = value;
            NotifyPropertyChanged("ContentScale");
        }
    }

    public void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    } 

    #region Commands

    bool CanZoomIn() { return true; }
    void ZoomInExecute()
    {
        ContentScale += 1.0;
    }

    public ICommand ZoomIn { get { return new RelayCommand(ZoomInExecute, CanZoomIn); } }

    #endregion
}

And the corresponding view:

<UserControl x:Class="PS_IDE.FormBuilder.View.Builder"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="clr-namespace:PS_IDE.FormBuilder.ViewModel">
    <UserControl.DataContext>
        <local:BuilderViewModel />
    </UserControl.DataContext>

    <TextBox Text="{Binding ContentScale}" Width="100" />

</UserControl>

I’m trying to have the ZoomIn command in BuilderViewModel update the text box value in it’s view. The command is being fired from another user control, UIBuilder, which includes Builder. If I debug and fire the command from UIBuilder, I can see it updating ContentScale properly.

However, my text box value does not get updated (it only says “1”, which is the initial value of ContentScale).

I know I’m missing something and hope someone can point me in the right direction.

EDIT: Added the control that is firing the command

<UserControl x:Class="PS_IDE.FormBuilder.UIBuilder"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:local="clr-namespace:PS_IDE.FormBuilder"
         xmlns:ViewModel="clr-namespace:PS_IDE.FormBuilder.ViewModel"
         xmlns:View="clr-namespace:PS_IDE.FormBuilder.View" mc:Ignorable="d">  
    <UserControl.DataContext>
        <ViewModel:BuilderViewModel />
    </UserControl.DataContext>
    <DockPanel LastChildFill="True">

        ....

        <ToolBarTray DockPanel.Dock="Bottom" HorizontalAlignment="Right">
            <ToolBar>
                <Button Height="24" Width="24" ToolTip="Zoom In" Command="{Binding ZoomIn}">
                    <Image Source="Images/ZoomIn.png" Height="16"/>
                </Button>

                ....

            </ToolBar>
       </ToolBarTray>
       <View:Builder x:Name="builder" />
    </DockPanel>
</UserControl>
  • 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-06-10T17:03:39+00:00Added an answer on June 10, 2026 at 5:03 pm

    With the setting in both view:

    <UserControl.DataContext>
        <local:BuilderViewModel />
    </UserControl.DataContext>
    

    you are basically creating two viewmodels, one for each view. So when your Command updates the property it does it on one of the viewmodel but your textbox is bound to a different viewmodel.

    To resolve it remove the DataContext setting from the Builder.xaml

    Additionally you need to pass your DataContext to your Builder control (with this both view will share the same viewmodel).

    So modify your UIBuilder.xaml:

    <View:Builder x:Name="builder" DataContext="{Binding}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first time posting here, I have a question which I have
Sorry, this's my first time to ask a question here. So, I don't have
I have the following situation: class A { public: A(int whichFoo); int foo1(); int
Following on from another question I have asked I have created a new class
Here is my problem in C# : I have the following classes: public class
Okay my question is the following: Say you have a class like below. During
First time poster here. A quick question about setting up a loop here. I
this is my first time asking a question here. I tried to be well
this is my first time asking a question so bear with me. I am
this is my first time asking a question on stackoverflow. I'm working on a

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.