views:

21

answers:

1

Everything compiles, but at run time a blank row is displayed. If I try to edit an entry, it says "No XPath set". What am I doing wrong? I tried a ton of variations, not having the INotifyPropertyChanged interface etc.

The base class is:

public class Variable : INotifyPropertyChanged 
    {
        public string Name;
        public string Value;

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }

The observable collection is:

 public class VariableCollection:ObservableCollection<Variable>
    {
         public VariableCollection()
            : base()
        {
        }

         public VariableCollection(List<Variable> list)
            : base(list)
        {
        }
    }

The binding is:

public VariablesView(VariableCollection variables)
        {
            InitializeComponent();

            gridContent.ItemsSource = variables;
        }   

The XAML is:

<DataGrid Name="gridContent" AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Name}" Header="Name" />
                <DataGridTextColumn Binding="{Binding Value}" Header="Value" />
            </DataGrid.Columns>
        </DataGrid>
+1  A: 

That is simple. You have fields in your class instead of properties.

Change the code to:

    public string Name{ get; set;}
    public string Value{ get; set;}
kubal5003
OMG I only wasted like four hours stuck on this. THANK YOU!
Kenoyer130