views:

18

answers:

1

I want to bind an 'ObservableCollection' to a Silverlight dataGrid and allow the contents to be editable.

I've got the following XAML, which allows the editing in the UI, but once I click off the row it changes back to the original.

I'm obviously missing something, any ideas?

    <sdk:DataGrid AutoGenerateColumns="False"
                  Height="81"
                  Margin="520,349,60,0"
                  Name="MessageBoxButtons"
                  ItemsSource="{Binding Path=ButtonsView}"
                  AlternatingRowBackground="Gainsboro"
                  RowBackground="White"
                  HeadersVisibility="All"
                  BorderThickness="2"
                  VerticalAlignment="Top"
                  CanUserSortColumns="False">                      
        <sdk:DataGrid.Columns>
            <sdk:DataGridTextColumn Binding="{Binding}"
                                    CanUserReorder="True"
                                    CanUserResize="True"
                                    CanUserSort="True"
                                    Width="*"
                                    Header="Button Text" />               
        </sdk:DataGrid.Columns>
    </sdk:DataGrid>
+1  A: 

Strings are immutable. That is, you cannot change the value of a specific instance of a string. What happens when you assign string values to strings is that a new String object is created and assigned to your variable.

Binding normally works on properties of objects. You are basically treating the string as both a source of data and a property that can be changed. The end result is that the value is changed then thrown away as the actual strings in the list are not replaced.

You want to have a list of simple objects that have string properties instead.

Enough already
obvious now you have point it out
AWC