As mentioned we made some changes, hopefully for the better, to the DataGrid API since Beta 2.  Special thanks to our developer Yifung Lin for compiling this list:

DataGrid breaking changes

DisplayMemberBinding renamed to Binding

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

DisplayMemberBinding wasn’t an ideal name, but we used it because WPF has some precedence with it.  This breaks down in scenarios where there is a separate Binding for display like in ComboBox scenarios since our Binding is actually the property field binding as opposed to the display binding.

Fix Required

Users using DataGridBoundColumn will need to change DisplayMemberBinding to Binding.

Beta 2

[Xaml]

<data:DataGridTextColumn DisplayMemberBinding="{Binding FirstName}" />

RTM

[Xaml]

<data:DataGridTextColumn Binding="{Binding FirstName}" />

 

DataGrid has VSM support

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

The DataGrid now supports the Visual State Manager.

Fix Required

Custom DataGrid templates need to be updated.  The new templates can be found at: http://msdn.microsoft.com/library/cc278066(vs.95).aspx

 

IEditableObject moved to System.ComponentModel namespace

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

In the full framework IEditableObject is part of the System.ComponentModel namespace and it is located in System.dll  For Silverlight, it was temporarily in the System.Windows.Controls.Data.dll under the System.Windows.Controls namespace.  It now  matches the full framework.

Fix Required

Users using IEditableObject need to update the namespace.

Beta 2

[c#]

using System.Windows.Controls;

RTM

[c#]

using System.ComponentModel;

 

SelectionChanged event changed from EventHandler to SelectionChangedEventHandler

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

Using SelectionChangedEventHandler allows the user to access OldItems and NewItems.

Fix Required

The signature for the SelectionChanged event handler needs to be updated.

Beta 2

[c#]

void SelectionChanged(object sender, EventArgs e)
{

}

RTM

[c#]

void SelectionChanged(object sender, SelectionChangedEventArgs e)
{

}

 

DataGridHeaders enum renamed to DataGridHeadersVisibility

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

DataGridHeadersVisibility is a better indication of what the enum is.

Fix Required

DataGridHeaders -> DataGridHeadersVisibility.

Beta 2

[c#]

dataGrid.HeadersVisibility = DataGridHeaders.Column;

RTM

[c#]

dataGrid.HeadersVisibility = DataGridHeadersVisibility.Column;

 

DataGridAutoGeneratingColumnEventArgs change

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

The PropertyInfo of DataGridAutoGeneratingColumnEventArgs was changed to PropertyName and PropertyType.

Fix Required

Update to use PropertyName and PropertyType.

Beta 2

[c#]

string name = e.Property.Name;
Type type = e.Property.Type;

RTM

[c#]

string name = e.PropertyName;
Type type = e.PropertyType;

 

DataGridColumn GenerateElement and GenerateEditingElement now take in the cell

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

GenerateElement and GenerateEditingElement now provide the containing cell

Fix Required

Update signature.

Beta 2

[c#]

protected override FrameworkElement GenerateEditingElement(object dataItem)
{

}

protected override FrameworkElement GenerateElement(object dataItem)
{ 

}

RTM

[c#]

protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{

}

protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{ 

}

 

DataGridColumnReorderingEventArgs changed

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

The following modifications were made to the DataGridColumnReorderingEventArgs:

Old:

public object DragIndicatorContent { get; set}
public FrameworkElement DropLocationIndicator { get; set}

New:

public Control DragIndicator { get; set}
public Control DropLocationIndicator { get; set}
Fix Required

Update to use DragIndicator.

Beta 2

[c#]

object dragIndicator = e.DragIndicatorContent;
FrameworkElement dropIndicator = e.DropLocationIndicator;

RTM

[c#]

Control dragIndicator = e.DragIndicator;
Control type = e.DropLocationIndicator;

 

DataGrid.CancelingEdit and DataGrid.CommittingEdit events removed

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

Explicit Binding is required to implement these 2 events correctly.  Since the Silverlight Binding does not support explicit Bindings, these events were removed.  They will be resurrected when explicit Binding is supported.

Fix Required

The DataGrid.CancelingEdit and the DataGrid.CommittingEdit events can no longer be used.  It is recommended that you use IEditableObject to track when a commit has occurred.

 

DataGrid.DataError event removed

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

The concept of a DataError event was taken from Winforms.  This does not fit well into the WPF model so the event was removed.

Fix Required

The DataGrid.DataError event can no longer be used.

 

DataGridColumn.Header no longer supports visuals

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

Visuals cannot be duplicated so they cannot be used for the Header property due to column reordering.

Fix Required

To put visuals in column headers, users will need to use the header's ContentTemplate to include the visual instead of setting it as the Header.

Beta 2

[Xaml]

<data:DataGridTextColumn DisplayMemberBinding="{Binding FirstName}">
    <data:DataGridTextColumn.Header>
        <Button Content="hello" />
    </data:DataGridTextColumn.Header>
</data:DataGridTextColumn>

RTM

[Xaml]

<data:DataGridTextColumn Binding="{Binding LastName}" Header="hello">
    <data:DataGridTextColumn.HeaderStyle>
        <Style TargetType="dataprimitives:DataGridColumnHeader">
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Button Content="{Binding}" />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </data:DataGridTextColumn.HeaderStyle>
</data:DataGridTextColumn>

 

Root element of DataGridRow changed from Grid to DataGridFrozenGrid

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

DataGridFrozenGrid derives from Grid and it contains an IsFrozen attached property.  Users can use IsFrozen to specify parts of the Row that are frozen

Fix Required

Custom DataGridRow templates need to use DataGridFrozenGrid as the root element instead of Grid.

 

Gridline renamed to GridLine

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

Gridline would be appropriate if it was a word.  MS Word says it is, but the dictionary says it’s not.  WPF has precedence with GridLine so we went with that.

Fix Required

All instances of Gridline need to be renamed to GridLine.

Beta 2

[c#]

dataGrid.GridlinesVisibility = DataGridGridlinesVisibility.All;

RTM

[c#]

dataGrid.GridLinesVisibility = DataGridGridLinesVisibility.All;

 

Template only controls moved to primitives namespace

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

These types moved from the System.Windows.Controls namespace to the System.Windows.Controls.Primitives namespace:

  • DataGridCellsPresenter
  • DataGridColumnHeadersPresenter
  • DataGridDetailsPresenter
  • DataGridRowsPresenter
  • DataGridColumnHeader
  • DataGridRowHeader
Fix Required

The types above need to be referenced using the System.Windows.Controls.Primitives namespace.

 

DataGridCheckBoxColumn.Content was removed

Who Is Affected: Silverlight 2 Beta 2 managed applications that use the DataGrid.

Summary

The Content property was not useful for mainline scenarios so it was removed.

Fix Required

The DataGridCheckBoxColumn.Content property can no longer be used.  In rare scenarios where it is needed, users can template the CheckBox through ElementStyle and EditingElementStyle