Стиль DataGrid
<Color x:Key="ClassroomHeaderColor">#FF2222FF</Color>
<SolidColorBrush x:Key="ClassroomHeaderBrush" Color="{StaticResource ClassroomHeaderColor}" />
<Style x:Key="AnnouncementsDataGrid" TargetType="{x:Type DataGrid}">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="BorderBrush" Value="#FF688CAF"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="MaxWidth" Value="1000" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGrid}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
<ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
<ScrollViewer.Template>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button Command="{x:Static DataGrid.SelectAllCommand}" Focusable="false" Style="{DynamicResource {ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}}" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
<DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.Column="1" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" Grid.ColumnSpan="2" Grid.Row="1"/>
<ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="2" Maximum="{TemplateBinding ScrollableHeight}" Orientation="Vertical" Grid.Row="1" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
<Grid Grid.Column="1" Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ScrollBar x:Name="PART_HorizontalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}" Orientation="Horizontal" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
</Grid>
</Grid>
</ControlTemplate>
</ScrollViewer.Template>
<!--#region Custom Modification -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Border Background="{StaticResource ClassroomHeaderBrush}" CornerRadius="8" Grid.Row="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition MinHeight="25" Height="Auto" />
<RowDefinition MinHeight="20" Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="16" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Content="{Binding CMCourse.Course.Name}" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" />
<Label Content="{Binding CMCourse.Course.Section}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" />
<Label Content="Class code" Grid.Row="2" Grid.Column="0"/>
<Label Content="{Binding CMCourse.Course.EnrollmentCode}" Grid.Row="2" Grid.Column="1" />
<!-- Creation and Update times -->
<Label Content="Created:" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" />
<Label Content="{Binding CMCourse.Course.CreationTime, StringFormat=g}" Grid.Row="2" Grid.Column="2" />
<Label Content="Last Updated:" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" />
<Label Content="{Binding CMCourse.Course.UpdateTime, StringFormat=g}" Grid.Row="3" Grid.Column="2" />
<!-- Course State -->
<Label Content="Course State:" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" />
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="2">
<ComboBox x:Name="NewCourseState"
IsReadOnly="True"
ItemsSource="{Binding NewCourseState}"
SelectedValuePath="Name"
SelectedItem="{Binding SelectedNewCourseState, Mode=TwoWay}"
DisplayMemberPath="Name">
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem">
<Setter Property="IsSelected" Value="{Binding IsSelected}" />
</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
<Button x:Name="ChangeCourseState" Content="Apply"/>
</StackPanel>
<!-- More Details Expander -->
<Expander Header="Details" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Content="Subject" Grid.Row="0" Grid.Column="0" />
<Label Content="{Binding CMCourse.Course.Subject, TargetNullValue='No subject set'}" Grid.Row="0" Grid.Column="1" />
<Label Content="Room" Grid.Row="1" Grid.Column="0" />
<Label Content="{Binding CMCourse.Course.Room, TargetNullValue='No room set'}" Grid.Row="1" Grid.Column="1" />
<Label Content="{Binding CMCourse.Course.Description, TargetNullValue='No description set'}" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" />
</Grid>
</Expander>
</Grid>
</Border>
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.Row="1" />
</Grid>
<!--#endregion Custom Modification-->
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true"/>
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</MultiTrigger>
</Style.Triggers>
</Style>
AnnouncementView - Пользовательский элемент управления, отображаемый DataGrid
<UserControl x:Class="ClassroomManager.Views.AnnouncementView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ClassroomManager.Views"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="400">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="1*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Row 0 -->
<Image x:Name="ProfilePic" Source="{Binding OwnerProfilePicURL}" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" />
<Label x:Name="OwnersName" Content="{Binding OwnerName}" Grid.Row="0" Grid.Column="1" />
<Label Content="State" Grid.Row="0" Grid.Column="2" />
<!-- Row 1-->
<Label x:Name="CreationTime" Content="{Binding CreationTimeText}" Grid.Row="1" Grid.Column="1" />
<Label x:Name="PostState" Content="{Binding StateText}" Grid.Row="1" Grid.Column="2" />
<!-- Row 2 -->
<TextBlock x:Name="AnnouncementText" Text="{Binding Announcement.Text}" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" />
</Grid>
</UserControl>