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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:13:38+00:00 2026-05-25T17:13:38+00:00

This is silverlight code – but I guess that this will be same in

  • 0

This is silverlight code – but I guess that this will be same in WPF –
I have this simple classes

public Class A1
{
      string str1;

      public string Str_1
      {
           return str1;
      }
 }

 public Class B1
 {
      A1 a1;

      public A1 A_1
      {
           return a1;
      }
  }

I assume that B1::A1.str1 have the value “my string”.

Now in the XAML I have this

<Grid x:Name="LayoutRoot" DataContext="B1">
   <StackPanel> 
      <TextBox Text="{Binding ElementName=A1, Path=Str_1, Mode=TwoWay}"/>
   </StackPanel>
</Grid>

In the the code ( xaml.cs ) i writing in the constructor this

  LayoutRoot.DataContext = this;    

( the B1 object is part of the xaml.cs file and the B1 is also not null and A1 is not null )

But ==> this is not working … and the text of the textbox is not update with the text that is in A1 object.

  • 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-25T17:13:38+00:00Added an answer on May 25, 2026 at 5:13 pm

    You are using element binding but A1 is not a named element in the Xaml page.

    You want Text={Binding Path=A_1.Str_1}

    This means that it points to the Str_1 property of the A_1 property of the data context (your code behind class).

    Please note that TwoWay is pointless here as you have no setters on your properties.

    To do this properly (assuming your values will change and be required) you need to implement setters on your A_1 and Str_1 properties and implement INotifyPropertyChanged on both your class A1 & B1.

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

Sidebar

Related Questions

I have the following Silverlight code: [ScriptableType] public partial class Page : UserControl {
In Silverlight I noticed that the code-behind Page class inherits from UserControl: public partial
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
If you use this code in Silverlight and WPF you get slightly different results?
I already have the answer for this using silverlight's System.JSON but specs got changed
I have come across this code snippet in a source code #if SILVERLIGHT internal
According to this article Silverlight 2 Beta 2 supports the DataContractJsonSerializer object. But, when
This is a for a Silverlight project that isn't anchored to an .aspx file,
I have downloaded the silver light from this http://www.microsoft.com/silverlight// I need to use this
I'm writing a silverlight application that resembles a shopping cart system. This app can

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.