TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Matthias Berger
NA
1
1.2k
Can someone help me - (Binding - Code behind)
Jul 31 2013 5:03 AM
I want to Bind a Textbox Value to a .NET Class in C# Code but it didn´t works :(
1. The Aim should be FieldName
public class DataClass : INotifyPropertyChanged
{
private string _FieldName;
public string FieldName
{
get { return _FieldName; }
set
{
if (_FieldName == value) return;
_FieldName = value;
OnPropertyChanged("Text");
}
}
#region Implementation of INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
2. This is the Binding: (name of the Textbox:txtName_)
Event MainWindow Loaded:
DataAim = new DataClass();
Binding myBinding = new Binding();
myBinding.Path = new PropertyPath("Text");
myBinding.Source = DataAim;
myBinding.Mode = BindingMode.TwoWay;
myBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
txtName_.SetBinding(TextBox.TextProperty, myBinding);
Can someone tell me what is wrong ?
Reply
Answers (
1
)
wpf mvvm listboxitem color changing
WPF Listboxitem text scroll on text length greater than 15