Click here to Skip to main content
15,912,329 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Another Expander Style Question Pin
Kevin Marois27-Mar-12 13:24
professionalKevin Marois27-Mar-12 13:24 
QuestionUnable to catch Key.Down in a combox with applied style Pin
George Nistor26-Mar-12 23:31
George Nistor26-Mar-12 23:31 
QuestionWPF Styling/Templating Problem Pin
Kevin Marois26-Mar-12 14:14
professionalKevin Marois26-Mar-12 14:14 
AnswerRe: WPF Styling/Templating Problem Pin
Abhinav S26-Mar-12 15:21
Abhinav S26-Mar-12 15:21 
GeneralRe: WPF Styling/Templating Problem Pin
Kevin Marois27-Mar-12 6:17
professionalKevin Marois27-Mar-12 6:17 
Questionhow to design Bubble chart with Datapoints like Piechart Pin
Tryxo26-Mar-12 12:11
Tryxo26-Mar-12 12:11 
QuestionMerge cells in C1Flexgrid for WPF Pin
Greeshma M J25-Mar-12 22:42
Greeshma M J25-Mar-12 22:42 
AnswerRe: Merge cells in C1Flexgrid for WPF Pin
Pete O'Hanlon26-Mar-12 0:06
mvePete O'Hanlon26-Mar-12 0:06 
QuestionXamDataGrid columns Pin
michaelgr125-Mar-12 22:22
michaelgr125-Mar-12 22:22 
GeneralRe: XamDataGrid columns Pin
michaelgr126-Mar-12 7:03
michaelgr126-Mar-12 7:03 
Questionwpf main container Pin
MemberDotNetting24-Mar-12 10:12
MemberDotNetting24-Mar-12 10:12 
AnswerRe: wpf main container Pin
Mycroft Holmes24-Mar-12 13:25
professionalMycroft Holmes24-Mar-12 13:25 
AnswerRe: wpf main container Pin
Abhinav S24-Mar-12 15:54
Abhinav S24-Mar-12 15:54 
GeneralRe: wpf main container Pin
MemberDotNetting30-Mar-12 22:24
MemberDotNetting30-Mar-12 22:24 
Questioncombining a textblock and textblock into one control Pin
Sutton Mehaffey23-Mar-12 19:58
Sutton Mehaffey23-Mar-12 19:58 
AnswerRe: combining a textblock and textblock into one control Pin
Mycroft Holmes23-Mar-12 21:58
professionalMycroft Holmes23-Mar-12 21:58 
GeneralRe: combining a textblock and textblock into one control Pin
Abhinav S24-Mar-12 0:10
Abhinav S24-Mar-12 0:10 
GeneralRe: combining a textblock and textblock into one control Pin
Sutton Mehaffey24-Mar-12 5:37
Sutton Mehaffey24-Mar-12 5:37 
GeneralRe: combining a textblock and textblock into one control Pin
Mycroft Holmes24-Mar-12 13:23
professionalMycroft Holmes24-Mar-12 13:23 
GeneralRe: combining a textblock and textblock into one control Pin
Sutton Mehaffey24-Mar-12 13:49
Sutton Mehaffey24-Mar-12 13:49 
GeneralRe: combining a textblock and textblock into one control Pin
Mycroft Holmes24-Mar-12 16:05
professionalMycroft Holmes24-Mar-12 16:05 
GeneralRe: combining a textblock and textblock into one control Pin
Sutton Mehaffey26-Mar-12 14:27
Sutton Mehaffey26-Mar-12 14:27 
GeneralRe: combining a textblock and textblock into one control Pin
Mycroft Holmes26-Mar-12 15:24
professionalMycroft Holmes26-Mar-12 15:24 
Not sure how you are set up but you are not implementing OnPropertyChange on your model public class ZoneDescEntry and your collections are generic rather than ObservableCollection this indicates that there is no notification about any changes to your data.

I use a BaseModel class that implements INotifyPropertyChanged and the Model implements IEditableObject this give me control of the editing process and I get notification of the data changes.

My BaseModel
HTML
public abstract class BaseModel : INotifyPropertyChanged
{

    public BaseModel() { }
    #region Events
    /// <summary>
    /// PropertyChanged event.
    /// </summary>
    public event PropertyChangedEventHandler PropertyChanged;
    #endregion


    private bool _IsDataChanged;
    public bool IsDataChanged
    {
        get
        { return _IsDataChanged; }
        set
        {
            if (_IsDataChanged == value)
            {
                return;
            }
            var oldValue = _IsDataChanged;
            _IsDataChanged = value;
            OnPropertyChanged("IsDataChanged");
        }
    }

    public void OnPropertyChanged(string propertyName)
    {
        PropertyChangedEventHandler handler = this.PropertyChanged;

        if (handler != null)
        {
            if (propertyName != "IsDataChanged")
            { IsDataChanged = true; }

            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    /// <summary>
    /// get a shallow copy of object of type T.
    /// objects with other object properties has not been tested.
    /// </summary>
    public static T ShallowCopy<T>(object objToCopy) where T : class, new()
    {
        if (objToCopy == null)
        { return null; }

        Type objType = typeof(T);
        object oValue;
        PropertyInfo oPropNew;
        T objNew = Activator.CreateInstance<T>(); //hence the new() contsraint
        //Debug.WriteLine(objType.Name + " = new " + objType.Name + "();");
        PropertyInfo[] oPInfos = objType.GetProperties();

        foreach (PropertyInfo oPInfo in oPInfos)
        {
            //may error if no mat
            oPropNew = objType.GetProperty(oPInfo.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
            oValue = oPInfo.GetValue(objToCopy, null);

            oPropNew.SetValue(objNew, oValue, null);
        }
        return objNew;
    }

    public static T ReverseCopy<T>(object EditableObject, object SelectedObject) where T : class, new()
    {
        if (EditableObject == null)
        { return null; }
        Type objType = typeof(T);
        object oValue;
        //Debug.WriteLine(objType.Name + " = new " + objType.Name + "();");
        PropertyInfo[] oPInfos = objType.GetProperties();
        foreach (PropertyInfo oPInfo in oPInfos)
        {
            //may error if no match
            PropertyInfo oPropNew = objType.GetProperty(oPInfo.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
            oValue = oPInfo.GetValue(EditableObject, null);
            oPropNew.SetValue(SelectedObject, oValue, null);
        }
        return (T)SelectedObject;
    }
}


The Model class
HTML
public class ZoneDescEntryDB : BaseModel, IEditableObject
{

    private string _ZoneNum;
    public string ZoneNum
    {
        get
        { return _ZoneNum; }
        set
        {
            if (_ZoneNum == value)
            {
                return;
            }
            var oldValue = _ZoneNum;
            _ZoneNum = value;
            base.OnPropertyChanged("ZoneNum");
        }
    }

    private string _ZoneDesc;
    public string ZoneDesc
    {
        get
        { return _ZoneDesc; }
        set
        {
            if (_ZoneDesc == value)
            {
                return;
            }
            var oldValue = _ZoneDesc;
            _ZoneDesc = value;
            base.OnPropertyChanged("ZoneDesc");
        }
    }

    #region                                             Edit methods
    private ZoneDescEntryDB Backup { get; set; }
    public void BeginEdit()
    {
        Backup = ShallowCopy<ZoneDescEntryDB>(this);
        IsDataChanged = false;
    }

    public void EndEdit()
    {
        Backup = null;
        IsDataChanged = false;
    }

    public void CancelEdit()
    {
        ReverseCopy<ZoneDescEntryDB>(Backup, this); Backup = null;
        IsDataChanged = false;
    }
    #endregion Edit methods

}

Never underestimate the power of human stupidity
RAH

GeneralRe: combining a textblock and textblock into one control Pin
Sutton Mehaffey26-Mar-12 16:01
Sutton Mehaffey26-Mar-12 16:01 
AnswerRe: combining a textblock and textblock into one control Pin
Abhinav S24-Mar-12 0:25
Abhinav S24-Mar-12 0:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.