This blog is primarily a compilation of frequently faced issues by developers with solutions which I have implemented to solve them
Thursday, April 2, 2015
JSonConverter - Serialize and Desrialize .Net
Solution Architect employed with Mercedes Benz with about 14 years of experience in Microsoft Technologies.
Wednesday, April 1, 2015
Solution for textBox text change not updating the view model/model
<TextBox Name="textBox1"
Height="23" Width="463"
HorizontalAlignment="Left"
Margin="12,12,0,0"
VerticalAlignment="Top"
Text="{Binding OriginalText, UpdateSourceTrigger=PropertyChanged}" />
TheTextBox.Text
property has a default UpdateSourceTrigger value of LostFocus. This means if an application has a TextBox with a data-bound TextBox.Text property, the text you type into the TextBox does not update the source until the TextBox loses focus (for instance, when you click away from the TextBox).If you want the source to get updated as you are typing, set the UpdateSourceTrigger of the binding to PropertyChanged. In the following example, the Text properties of both the TextBox and the TextBlock are bound to the same source property. The UpdateSourceTrigger property of the TextBox binding is set to PropertyChanged.
Labels:
Binding,
Model,
TextBox TextChangedEvent,
ViewModel,
WPF
Solution Architect employed with Mercedes Benz with about 14 years of experience in Microsoft Technologies.
Serialization Exception: PropertyChangedEventManager is not serializable
Since events are non serializable, here is the way out to deal the problem when serializing model classes which have a property changed event to notify the view model classes:
http://www.primordialcode.com/blog/post/serialization-exception-propertychangedeventmanager-serializable
[NonSerialized] private PropertyChangedEventHandler _PropertyChanged; public virtual event PropertyChangedEventHandler PropertyChanged { add { _PropertyChanged += value; } remove { _PropertyChanged -= value; } }
Labels:
Model classes,
MVVM,
Serialization,
ViewModel classes,
WPF
Solution Architect employed with Mercedes Benz with about 14 years of experience in Microsoft Technologies.
Subscribe to:
Posts (Atom)