public override Style SelectStyle(object item, DependencyObject container) { DataGridRow dgr = container as DataGridRow; MediaItem mediaItem = item as MediaItem; if (mediaItem != null) { if (mediaItem.IsHidden) { return((Style)dgr.FindResource("hiddenMediaItemRowStyle")); } } return(base.SelectStyle(item, container)); }
private void DataGrid_LoadingRow(object sender, DataGridRowEventArgs eventArgs) { log.DebugFormat("Loading row for item {0}", eventArgs.Row.Item); DataGridRow row = eventArgs.Row; if (dataGrid.RowStyleSelector != null) { Style rowStyle = dataGrid.RowStyleSelector.SelectStyle(eventArgs.Row.Item, eventArgs.Row); if (rowStyle == null) { var rowStyleKey = FrameworkElementAccessor.GetDefaultStyleKeyProperty(row); rowStyle = row.FindResource(rowStyleKey) as Style; } log.DebugFormat("Applying row style: {0}", rowStyle); row.Style = rowStyle; } }