[Last Call] Learn how to a build a cloud-first strategyRegister Now


How do you databind in WPF to a local variable

Posted on 2010-01-03
Medium Priority
Last Modified: 2013-11-12
In my code-behind, I have a variable

public class X
    private String foo;

What is needed in the class and the XAML form to make it data bound?

What is the binding syntax for the XAML?

Question by:bryan_z
  • 2
LVL 11

Accepted Solution

ashraf882 earned 75 total points
ID: 26166114

Assisted Solution

sureshchsahu earned 75 total points
ID: 26168883

Author Comment

ID: 26183239

Thanks for the information but neither article provided me specifically what I was looking for. In the end I found the following article which provided the details:


I have included a snippet of what i did to get things working.
factory = new BookFactory();
factory.SelectedIndex = 0;

ObjectDataProvider provider = (ObjectDataProvider)FindResource("theBook");            
provider.ObjectInstance = factory;

   <ObjectDataProvider  MethodName="GetTheBook"  x:Key="theBook"/>

<TextBlock Height="23" HorizontalAlignment="Left" Margin="126,95,0,0" Name="textBlock1" 
Text="{Binding Source={StaticResource theBook},Path=Title}" 
       VerticalAlignment="Top" Width="270" />

Open in new window


Author Closing Comment

ID: 31672128
Both articles provided several good details on data bindings but where not complete and directly associated to the question. I did use them to find a 3rd article which had the specific information regarding the object data binder.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question