473,398 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

WPF Binding To Object Not Working

Hello,

My first attempt to bind a 'detail' form to the properties on an object and
the binding is not working.

I have the following grid:

<Grid x:Name="MainGrid">
<StackPanel FlowDirection="LeftToRight">
<TextBlock Foreground="#FFFFFFFF">First name:</TextBlock>
<TextBox Text="{Binding Path=UserName}"></TextBox>
</StackPanel>
</Grid>

And the code behind on the load for the form runs the following... its
definitely executing and the UserName property of _user is set to "Phillip",
but nothing displays in the text box detailed above!

this.MainGrid.DataContext = _user;

Is there some obvious properties or calls I need to set or make to get a
simple binding app like this to work? Or am I missing something else?

Thanks.
--
Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com
Mar 5 '08 #1
2 2055
I'm no expert on this, but I think you need to specify the object that
has the UserName property in your Binding regardless of the
DataContext. Also, is UserName a DependencyProperty? You should
probably invest in some WPF books to get you started.
Mar 5 '08 #2
Thanks for the response...

I've read a bit about it in Essential Windows Presentation Foundation by
Chris Anderson and I'm also looking at this tutorial....

http://coredotnet.blogspot.com/2006/...-tutorial.html

The only thing different in my code is my object does not currently
implement the INotifyPropertyChanged interface, but in Chris Anderson's book
he says that's optional.

Might try implementing the interface and seeing if it binds... not too
hopeful though. If anybody has any ideas I would be grateful.
--
Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com
"not_a_commie" wrote:
I'm no expert on this, but I think you need to specify the object that
has the UserName property in your Binding regardless of the
DataContext. Also, is UserName a DependencyProperty? You should
probably invest in some WPF books to get you started.
Mar 6 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jesse | last post by:
Hi All, I've been working on a form that has several bound controls that all link to one table in a dataset. In the table, there is a column for the filename of jpeg images related to each...
9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
2
by: Boniek | last post by:
Hi, How I can create property to binding with other objects. I want to create a data object which work as a DataTable. DataTable contains columns and dataTable is used to binding with a textBox...
19
by: Simon Verona | last post by:
I'm not sure if I'm going down the correct route... I have a class which exposes a number of properties of an object (in this case the object represents a customer). Can I then use this...
2
by: David Veeneman | last post by:
I want to data bind a user control and a business object, using a BindingSource control. The control has a 'Priority' property that takes a 'Priority' enum (High, Normal, Low). The business object...
3
by: TS | last post by:
when binding to a datagrid for example, is it possible to use databinding syntax to bind to a property of a property? Say the datasource="Cars" which is a collection of car classes and the...
6
by: Mikus Sleiners | last post by:
Is there any way to enable exception throws in VS 2005, that occur during binding operations? I am upset that i can't see exceptions that are thrown during binding operations. It's very hard to...
9
by: =?Utf-8?B?VGVycnk=?= | last post by:
Think it is great the way that you can set up a datsource, value member, and display member for a combobox, and map a 'code' to a 'description' and back again by binding the combobox to a...
5
by: =?Utf-8?B?VGVycnk=?= | last post by:
Hi, I have a couple of labels on a form and their visible property is bound to boolean properties on a custom object. When I first load the form, all works as it should. This form is 'tied'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.