Three rectangles in WPF progressbar style - wpf

Currently i was fixed border width="750" but i want to divide progress-bar width="*" so our defined colors (red,green,blue) utilize all window width of different resolution screens and our colors starts from (left,center,right) of the page(not with each other), when one color disappear (complete circle) it must start again from left side of the page. I was modified the style, but its not worked such i want.
<LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill" StartPoint="0,0.5" EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="White" Offset="0" />
<GradientStop Color="Chocolate" Offset="0.4" />
<GradientStop Color="Chocolate" Offset="0.6" />
<GradientStop Color="White" Offset="1" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<Style TargetType="{x:Type ProgressBar}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ProgressBar}">
<Grid MinHeight="14" MinWidth="400" Background="{TemplateBinding Background}">
<Border x:Name="PART_Track" CornerRadius="2" BorderThickness="1">
<Border.BorderBrush>
<SolidColorBrush Color="#FFFFFF" />
</Border.BorderBrush>
</Border>
<Border x:Name="PART_Indicator" CornerRadius="2" BorderThickness="1" HorizontalAlignment="Left"
Background="{TemplateBinding Foreground}" Margin="0,-1,0,1">
<Grid ClipToBounds="True" x:Name="Animation">
<Border x:Name="PART_GlowRect" Width="750" HorizontalAlignment="Left"
Background="Transparent" Margin="0,0,0,0" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}" />
<Rectangle Grid.Column="1" Fill="Transparent" />
<Rectangle Grid.Column="2" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}" />
<Rectangle Grid.Column="3" Fill="Transparent" />
<Rectangle Grid.Column="4" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}" />
</Grid>
</Border>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="#FFFFFF"/>

I think the ProgressBar control is not easily modifiable to achieve what you need, but you can create a similar effect with some simple animations:
<Grid Height="50" Width="300" Background="DarkGray" ClipToBounds="True">
<Grid x:Name="grid1" Width="300" HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="Red" />
<Rectangle Grid.Column="1" Fill="Green" />
<Rectangle Grid.Column="2" Fill="Blue" />
<Grid.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<ThicknessAnimation Storyboard.TargetName="grid1"
Storyboard.TargetProperty="Margin" From="0,0,0,0" To="300,0,0,0"
Duration="0:0:3" BeginTime="0:0:0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
</Grid>
<Grid x:Name="grid2" Width="300" HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="Red" />
<Rectangle Grid.Column="1" Fill="Green" />
<Rectangle Grid.Column="2" Fill="Blue" />
<Grid.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<ThicknessAnimation Storyboard.TargetName="grid2"
Storyboard.TargetProperty="Margin" From="-300,0,0,0" To="0,0,0,0"
Duration="0:0:3" BeginTime="0:0:0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
</Grid>
</Grid>
In the code above you have two identical Grids (grid1 and grid2), the only difference lies in their animation: they are both moving from left to right with the same speed, but in a different phase, so they create the illusion, that once a color disappears at the right side, it comes back from the left.
The ClipToBounds="True" setting of the outmost Grid ensures that no drawing will be done outside that grid.
If you are keen on using a ProgressBar, you can modify the PART_Track to contain the Grid from above, and completely skip the PART_Indicator and PART_GlowRect. Here is your code modified in this way (and put into a Page):
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.Resources>
<LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill" StartPoint="0,0.5" EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Offset="0" Color="White"/>
<GradientStop Offset="0.4" Color="Chocolate"/>
<GradientStop Offset="0.6" Color="Chocolate"/>
<GradientStop Offset="1" Color="White"/>
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<Style TargetType="{x:Type ProgressBar}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ProgressBar}">
<Grid
MaxWidth="750"
MinHeight="14"
MinWidth="400"
Background="{TemplateBinding Background}">
<Border x:Name="PART_Track" BorderThickness="1" CornerRadius="2">
<Border.BorderBrush>
<SolidColorBrush Color="#FFFFFF"/>
</Border.BorderBrush>
<Grid ClipToBounds="True">
<Grid x:Name="grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}"/>
<Rectangle Grid.Column="1" Fill="Transparent"/>
<Rectangle Grid.Column="2" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}"/>
<Rectangle Grid.Column="3" Fill="Transparent"/>
<Rectangle Grid.Column="4" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}"/>
<Grid.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<ThicknessAnimation
BeginTime="0:0:0"
Duration="0:0:3"
From="0,0,0,0"
Storyboard.TargetName="grid1"
Storyboard.TargetProperty="Margin"
To="900,0,0,0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
</Grid>
<Grid x:Name="grid2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}"/>
<Rectangle Grid.Column="1" Fill="Transparent"/>
<Rectangle Grid.Column="2" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}"/>
<Rectangle Grid.Column="3" Fill="Transparent"/>
<Rectangle Grid.Column="4" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}"/>
<Grid.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<ThicknessAnimation
BeginTime="0:0:0"
Duration="0:0:3"
From="-900,0,0,0"
Storyboard.TargetName="grid2"
Storyboard.TargetProperty="Margin"
To="0,0,0,0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
</Grid>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="#FFFFFF"/>
</Style>
</Grid.Resources>
<ProgressBar IsIndeterminate="True"/>
</Grid>
</Page>
I hope this helps.

Related

WPF Material design date picker (select range aka range picker)

I have been searching quite a lot and not able to find any solution available, so I have decided to ask here. I am currently using WPF Material design for several controls (https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit). Date Picker works fine, however I have came up to the point when I need to select range of dated and not a single one. I need to be able to do like this:
Is there any way to select range instead of single date?
Here is part of my code for Datepicker.xaml:
<DatePicker x:Name="ReportDateTimePicker" HorizontalAlignment="Center" VerticalAlignment="Center" Height="40"
Padding="0,3,0,0" Margin="10,1,10,-1" FirstDayOfWeek="Monday" Width="148"
FontFamily="{StaticResource Roboto}"
CalendarStyle="{DynamicResource DatePickerCalendarStyle}"
SelectedDate="{Binding StartDate}"/>
Also this part is from style datetimepicker.xaml:
<Style TargetType="{x:Type DatePicker}">
<Setter Property="Foreground" Value="#FF333333" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="IsTodayHighlighted" Value="True" />
<!--<Setter Property="SelectedDateFormat" Value="Short" />-->
<Setter Property="Padding" Value="0" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<!--Set CalendarStyle to DatePickerCalendarStyle.-->
<Setter Property="CalendarStyle" Value="{DynamicResource DatePickerCalendarStyle}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DatePicker}">
<Border BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource BorderLightColor}" Offset="0" />
<GradientStop Color="{DynamicResource BorderDarkColor}" Offset="1" />
</LinearGradientBrush>
</Border.BorderBrush>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Transparent" Offset="0" />
<GradientStop Color="Transparent" Offset="1" />
</LinearGradientBrush>
</Border.Background>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Duration="0"
To="1"
Storyboard.TargetProperty="Opacity"
Storyboard.TargetName="PART_DisabledVisual" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="PART_Root"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button x:Name="PART_Button"
Grid.Column="1"
Foreground="{TemplateBinding Foreground}"
Focusable="False"
HorizontalAlignment="Left"
Margin="3,0,3,0"
Grid.Row="0"
Style="{StaticResource DropDownButtonStyle}"
VerticalAlignment="Center" />
<DatePickerTextBox x:Name="PART_TextBox"/>
<Grid x:Name="PART_DisabledVisual"
Grid.ColumnSpan="2"
Grid.Column="0"
IsHitTestVisible="False"
Opacity="0"
Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0"
Fill="#A5FFFFFF"
RadiusY="1"
Grid.Row="0"
RadiusX="1" />
<Rectangle Grid.Column="1"
Fill="Transparent"
Height="30"
Margin="3,0,3,0"
RadiusY="1"
Grid.Row="0"
RadiusX="1"
Width="260"/>
<Popup x:Name="PART_Popup"
AllowsTransparency="True"
Placement="Bottom"
PlacementTarget="{Binding ElementName=PART_TextBox}"
StaysOpen="False" />
</Grid>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

Silverlight datagrid virtualization creating issues in scrolling

I have a Datagrid with two columns. First column contains a DataTemplate with a custom control in it. I have set MaxHeight and VerticalScrollbarvisibility=Auto on Datagrid. When the grid contains approx 20 rows scroll bar becomes visible. Upon scrolling quickly data in bottom or upper rows is not reflecting properly (perhaps due to virtualization, it shows data from previous cells). So i have a couple of questions -
Is it possible to turn off virtualization? I am using silverlight 5.
Is it possible to fix the grid headers and put the grid itself in a scroll viewer so that it gives the impression of grids own scroll bar.
Any help is greatly appreciated.
Thanks
Yes it is possible to turn off virtualization.
I had exactly the same problem as you - this custom style turns off virtualization and works like a charm:
<Style x:Key="NonVirtualizingDataGridStyle" TargetType="sdk:DataGrid">
<Setter Property="RowBackground" Value="#EBEBED" />
<Setter Property="AlternatingRowBackground" Value="#EBEBED" />
<Setter Property="RowHeight" Value="25" />
<Setter Property="GridLinesVisibility" Value="All"/>
<Setter Property="HeadersVisibility" Value="Column" />
<Setter Property="HorizontalGridLinesBrush" Value="#A0A0A0" />
<Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="SelectionMode" Value="Single" />
<Setter Property="CanUserReorderColumns" Value="False" />
<Setter Property="CanUserResizeColumns" Value="False" />
<Setter Property="CanUserSortColumns" Value="True" />
<Setter Property="AutoGenerateColumns" Value="True" />
<Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="sdk:DataGrid">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="2">
<Grid x:Name="Root" Background="{TemplateBinding Background}">
<Grid.Resources>
<!--Start: TopLeftHeaderTemplate-->
<ControlTemplate x:Key="TopLeftHeaderTemplate" TargetType="sdk:DataGridColumnHeader">
<Grid x:Name="Root">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border BorderThickness="0,0,1,0" BorderBrush="#FFC9CACA" Background="#FF1F3B53" Grid.RowSpan="2">
<Rectangle Stretch="Fill" StrokeThickness="1">
<Rectangle.Fill>
<LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
<GradientStop Color="#FCFFFFFF" Offset="0.015" />
<GradientStop Color="#F7FFFFFF" Offset="0.375" />
<GradientStop Color="#E5FFFFFF" Offset="0.6" />
<GradientStop Color="#D1FFFFFF" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Border>
<Rectangle VerticalAlignment="Bottom" Width="Auto" StrokeThickness="1" Height="1" Fill="#FFDBDCDC" Grid.RowSpan="2" />
</Grid>
</ControlTemplate>
<!--End: TopLeftHeaderTemplate-->
<!--Start: TopRightHeaderTemplate-->
<ControlTemplate x:Key="TopRightHeaderTemplate" TargetType="sdk:DataGridColumnHeader">
<Grid x:Name="RootElement">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border BorderThickness="1,0,0,0" BorderBrush="#FFC9CACA" Background="#FF1F3B53" Grid.RowSpan="2">
<Rectangle Stretch="Fill">
<Rectangle.Fill>
<LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
<GradientStop Color="#FCFFFFFF" Offset="0.015" />
<GradientStop Color="#F7FFFFFF" Offset="0.375" />
<GradientStop Color="#E5FFFFFF" Offset="0.6" />
<GradientStop Color="#D1FFFFFF" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Border>
</Grid>
</ControlTemplate>
<!--End: TopRightHeaderTemplate-->
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- Fill up the space in the header above the vertical scroll bar -->
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="0.5*" />
<RowDefinition Height="0.5*" />
</Grid.RowDefinitions>
<!--<Rectangle x:Name="BackgroundGradient" Stretch="Fill" Fill="#FF79C1C0" Grid.RowSpan="2"/>
<Rectangle x:Name="BackgroundGradient_Copy" Fill="#6BFFFFFF" VerticalAlignment="Stretch" Grid.RowSpan="1"/>-->
<Rectangle x:Name="BackgroundGradient" Stretch="Fill"
Fill="{StaticResource CustomRed}" Grid.ColumnSpan="2"
Grid.RowSpan="2" />
<Border BorderBrush="Transparent"
BorderThickness="1,1,1,1"
Grid.ColumnSpan="3" Grid.RowSpan="3">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<!--dark-->
<Border HorizontalAlignment="Stretch"
Margin="0,0,0,0" x:Name="dark"
Width="Auto" Grid.ColumnSpan="3"
Grid.RowSpan="3"
Background="#66000000"
Opacity="0"/>
<!--glow-->
<Border Opacity="0"
HorizontalAlignment="Stretch" x:Name="glow"
Width="Auto" Grid.RowSpan="2"
Grid.ColumnSpan="3">
<Border.Background>
<RadialGradientBrush>
<RadialGradientBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform ScaleX="1.7"
ScaleY="2.2"/>
<SkewTransform AngleX="0"
AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="-0.3"
Y="-0.1"/>
</TransformGroup>
</RadialGradientBrush.RelativeTransform>
<GradientStop Color="#B2FFFFFF"
Offset="0"/>
<GradientStop Color="#00FFFFFF"
Offset="1"/>
</RadialGradientBrush>
</Border.Background>
</Border>
<!--shine-->
<Border HorizontalAlignment="Stretch"
Margin="0,0,0,0" x:Name="shine"
Width="Auto"
Grid.ColumnSpan="3">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,0.9"
StartPoint="0.5,0.1">
<GradientStop Color="#99FFFFFF"
Offset="0"/>
<GradientStop Color="#33FFFFFF"
Offset="1"/>
</LinearGradientBrush>
</Border.Background>
</Border>
</Grid>
</Border>
</Grid>
<sdk:DataGridColumnHeader x:Name="TopLeftCornerHeader" Template="{StaticResource TopLeftHeaderTemplate}" Width="22" />
<sdk:DataGridColumnHeadersPresenter Grid.Column="1" x:Name="ColumnHeadersPresenter" HorizontalAlignment="Left"/>
<sdk:DataGridColumnHeader x:Name="TopRightCornerHeader" Grid.Column="2" Template="{StaticResource TopRightHeaderTemplate}" />
<Rectangle x:Name="ColumnHeadersAndRowsSeparator" Grid.ColumnSpan="3" VerticalAlignment="Bottom" Width="Auto" StrokeThickness="1" Height="1" Fill="#FFC9CACA"/>
<ScrollViewer Style="{StaticResource RowScrollViewerStyle}" Grid.ColumnSpan="2" Grid.Row="1" Padding="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" >
<sdk:DataGridRowsPresenter x:Name="RowsPresenter" />
</ScrollViewer>
<Rectangle x:Name="BottomRightCorner" Fill="#FFE9EEF4" Grid.Column="2" Grid.Row="2" />
<Rectangle x:Name="BottomLeftCorner" Fill="#FFE9EEF4" Grid.Row="2" Grid.ColumnSpan="2" />
<Grid Grid.Column="1" Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Rectangle x:Name="FrozenColumnScrollBarSpacer" />
<!--<local:Navigator Margin="4,0,2,0" />-->
<ScrollBar x:Name="HorizontalScrollbar" Grid.Column="1" Orientation="Horizontal" Height="18" Margin="-1,0,-1,-1" />
</Grid>
</Grid>
</Border>
<Border x:Name="DisabledVisualElement" IsHitTestVisible="False" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" CornerRadius="2" Background="#8CFFFFFF" Opacity="0"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
There is a more simple style used to turn off virtualization but the one above has modifications to freeze the grid headers. I have just dumped the style that i use, you may want to remove the styling - but the functionality is there.
This style will solve your 2 points.

How to remove border around the DataGrid in silverlight

How do i remove the border around the Data grid in silverlight when i try BorderThickness="0" BorderBrush="Transparent" it gets rid of the broder on right left and bottom of the grid but not the top i think thats the header border or something but unsure i have also removed headers HeadersVisibility="None"
would be great if someone could help.
Cheers
In Silverlight 2 Beta 2 the generated DataGrid is surrounded by a border. Unfortunately, the removal of this border cannot be accomplished by simply setting a property on the DataGrid. To remove this, the definition of the DataGrid style or "skin" will need to be overridden.
The appearance for each Silverlight control (FrameworkElement) is defined within a ControlTemplate. Using Styles, this template can be overridden within your application with a set of customized XAML code. Default XAML definitions are found within the Silverlight Control Styles and Templates documentation. Specific to this topic, XAML definitions for the DataGrid are found in the DataGrid Styles and Templates documentation.
In the DataGrid XAML, look for the Template definition. Once this has been located, note that the RootElement of the the DataGrid is surrounded by three distinct Border elements.
These elements are likely the items that need to be removed. To start the customization, the style XAML for the DataGrid will need to be added as a new resource into our application. I'm going to add this directly to my UserControl, but it could also be added to the Application resources (in App.xaml).
To add the XAML to the UserControl create a new node named UserControl.Resources and copy the DataGrid XAML into it (use the handy "Copy Code" link on the documentation web page).
The namespace definitions for the DataGrid and the Resource must match. In the copied XAML the namespace is local:DataGrid. The default namespace generated by the Visual Studio tool is my:DataGrid. In the above example, I changed all references of local to my.
The next item to take care of is that the Style must have a Key. This is used to map a Framework element (our DataGrid) to a specific style definition. I've given the style a key of TestGrid which is used in the following DataGrid definition.
At this point, when you run the application the DataGrid should appear exactly as it did before (we haven't changed anything yet).
Before I start removing the definitions for the Border elements, I want to make sure that these are the culprits. To do this, I'm going to change their colors to something a little more obvious.
Running the application, I get the a screen
Zooming in, it's obvious how these elements take part in the display of the DataGrid.
Removing the Border elements from the XAML generates the desired results.
Hopefully, this not only provides a reference for how to remove the border from a DataGrid, but also provides a quick introduction to the possibilities available for customizing Silverlight controls.
Copied from: http://devcenter.auburnrandall.com/Default.aspx?type=post&id=52
The element you are seeing it is a Rectangle called ColumnHeadersAndRowsSeparator. Just create a Style without it:
<Style TargetType="sdk:DataGrid">
<Setter Property="RowBackground" Value="#AAEAEFF4" />
<Setter Property="AlternatingRowBackground" Value="#00FFFFFF" />
<Setter Property="Background" Value="#FFFFFFFF" />
<Setter Property="HeadersVisibility" Value="Column" />
<Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="SelectionMode" Value="Extended" />
<Setter Property="CanUserReorderColumns" Value="True" />
<Setter Property="CanUserResizeColumns" Value="True" />
<Setter Property="CanUserSortColumns" Value="True" />
<Setter Property="AutoGenerateColumns" Value="True" />
<Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected" />
<Setter Property="BorderBrush">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFA3AEB9" Offset="0"/>
<GradientStop Color="#FF8399A9" Offset="0.375"/>
<GradientStop Color="#FF718597" Offset="0.375"/>
<GradientStop Color="#FF617584" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="1" />
<Setter Property="DragIndicatorStyle">
<Setter.Value>
<!-- TODO: Change the TargetType to Control when the fix Jolt bugs 18719 is verified -->
<Style TargetType="ContentControl">
<Setter Property="Foreground" Value="#7FFFFFFF" />
<Setter Property="Template">
<Setter.Value>
<!-- TODO: Change the TargetType to Control when the fix Jolt bugs 18719 is verified -->
<ControlTemplate TargetType="ContentControl">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SortStates">
<VisualState x:Name="Unsorted" />
<VisualState x:Name="SortAscending">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity" Duration="0" To="1.0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="SortDescending">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity" Duration="0" To="1.0"/>
<DoubleAnimation Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="(RenderTransform).ScaleY" Duration="0" To="-.9"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="BackgroundRectangle" Stretch="Fill" Fill="#66808080" Grid.ColumnSpan="2" />
<Rectangle x:Name="BackgroundGradient" Stretch="Fill" Grid.ColumnSpan="2" Opacity="0" >
<Rectangle.Fill>
<LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
<GradientStop Color="#FFFFFFFF" Offset="0.015" />
<GradientStop Color="#F9FFFFFF" Offset="0.375" />
<GradientStop Color="#E5FFFFFF" Offset="0.6" />
<GradientStop Color="#C6FFFFFF" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter Content="{TemplateBinding Content}"/>
<Path Grid.Column="1" Name="SortIcon" Fill="#7FFFFFFF" RenderTransformOrigin=".5,.5" HorizontalAlignment="Left" VerticalAlignment="Center" Opacity="0" Stretch="Uniform" Width="8" Margin="4,0,0,0" Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z ">
<Path.RenderTransform>
<ScaleTransform ScaleX=".9" ScaleY=".9" />
</Path.RenderTransform>
</Path>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="DropLocationIndicatorStyle">
<Setter.Value>
<Style TargetType="ContentControl">
<Setter Property="Background" Value="#FF3F4346"/>
<Setter Property="Width" Value="2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContentControl">
<Rectangle Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="GridLinesVisibility" Value="Vertical" />
<Setter Property="HorizontalGridLinesBrush" Value="#FFC9CACA" />
<Setter Property="IsTabStop" Value="True" />
<Setter Property="VerticalGridLinesBrush" Value="#FFC9CACA" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="sdk:DataGrid">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="2">
<Grid Name="Root" Background="{TemplateBinding Background}">
<Grid.Resources>
<!--Start: TopLeftHeaderTemplate-->
<ControlTemplate x:Key="TopLeftHeaderTemplate" TargetType="localprimitives:DataGridColumnHeader">
<Grid Name="Root">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border BorderThickness="0,0,1,0" BorderBrush="#FFC9CACA" Background="#FF1F3B53" Grid.RowSpan="2">
<Rectangle Stretch="Fill" StrokeThickness="1">
<Rectangle.Fill>
<LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
<GradientStop Color="#FCFFFFFF" Offset="0.015" />
<GradientStop Color="#F7FFFFFF" Offset="0.375" />
<GradientStop Color="#E5FFFFFF" Offset="0.6" />
<GradientStop Color="#D1FFFFFF" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Border>
<Rectangle VerticalAlignment="Bottom" Width="Auto" StrokeThickness="1" Height="1" Fill="#FFDBDCDC" Grid.RowSpan="2"/>
</Grid>
</ControlTemplate>
<!--End: TopLeftHeaderTemplate-->
<!--Start: TopRightHeaderTemplate-->
<ControlTemplate x:Key="TopRightHeaderTemplate" TargetType="localprimitives:DataGridColumnHeader">
<Grid Name="RootElement">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border BorderThickness="1,0,0,0" BorderBrush="#FFC9CACA" Background="#FF1F3B53" Grid.RowSpan="2">
<Rectangle Stretch="Fill">
<Rectangle.Fill>
<LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
<GradientStop Color="#FCFFFFFF" Offset="0.015" />
<GradientStop Color="#F7FFFFFF" Offset="0.375" />
<GradientStop Color="#E5FFFFFF" Offset="0.6" />
<GradientStop Color="#D1FFFFFF" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Border>
</Grid>
</ControlTemplate>
<!--End: TopRightHeaderTemplate-->
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<localprimitives:DataGridColumnHeader Name="TopLeftCornerHeader" Template="{StaticResource TopLeftHeaderTemplate}" Width="22" />
<localprimitives:DataGridColumnHeadersPresenter Name="ColumnHeadersPresenter" Grid.Column="1"/>
<localprimitives:DataGridColumnHeader Name="TopRightCornerHeader" Grid.Column="2" Template="{StaticResource TopRightHeaderTemplate}" />
<!-- HERE IT IS THAT LINE YOU SEE -->
<!--<Rectangle Name="ColumnHeadersAndRowsSeparator" Grid.ColumnSpan="3" VerticalAlignment="Bottom" Width="Auto" StrokeThickness="1" Height="1" Fill="#FFC9CACA"/>-->
<localprimitives:DataGridRowsPresenter Name="RowsPresenter" Grid.ColumnSpan="2" Grid.Row="1" />
<Rectangle Name="BottomRightCorner" Fill="#FFE9EEF4" Grid.Column="2" Grid.Row="2" />
<Rectangle Name="BottomLeftCorner" Fill="#FFE9EEF4" Grid.Row="2" Grid.ColumnSpan="2" />
<ScrollBar Name="VerticalScrollbar" Orientation="Vertical" Grid.Column="2" Grid.Row="1" Width="18" Margin="0,-1,-1,-1"/>
<Grid Grid.Column="1" Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Rectangle Name="FrozenColumnScrollBarSpacer" />
<ScrollBar Name="HorizontalScrollbar" Grid.Column="1" Orientation="Horizontal" Height="18" Margin="-1,0,-1,-1"/>
</Grid>
</Grid>
</Border>
<Border x:Name="DisabledVisualElement" IsHitTestVisible="False" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" CornerRadius="2" Background="#8CFFFFFF" Opacity="0"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

How can I animate the y-scale in a custom TabControl?

i have modify and simplify the TabControl for my work. Now i will Animate the Chang between two TabItems - The Y-Scale not longer as hartcut but with a soft slide - do you know how can i do this?
Thanks a lot.
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
x:Class="tabControl.MainWindow" x:Name="Window" Title="MainWindow" Width="640" Height="480">
<Window.Resources>
<Style x:Key="TabControlStyle1" TargetType="{x:Type TabControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid x:Name="grid" ClipToBounds="true" SnapsToDevicePixels="true"
KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="0" />
</Grid.RowDefinitions>
<StackPanel IsItemsHost="True" />
<Border x:Name="ContentPanel" Grid.Column="1"
KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="0"
KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local"
VerticalAlignment="Top">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="Top" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid x:Name="LayoutRoot">
<StackPanel Margin="150,100">
<TabControl Style="{DynamicResource TabControlStyle1}">
<TabItem Header="TabItem">
<Grid Background="red" Height="100" />
</TabItem>
<TabItem Header="TabItem">
<Grid Background="blue" Height="200" />
</TabItem>
<TabItem Header="TabItem">
<Grid Background="yellow" Height="100" />
</TabItem>
</TabControl>
<Border Background="Azure" Height="200" BorderBrush="Black" BorderThickness="1" />
</StackPanel>
</Grid>
<!-- ... -->
Thank you for your help.
i have extend my style with the VisualStateGroup of your example but it doesn't work. Maybe something is different between the ListBox and the TabControl?
<Style x:Key="TabControlStyle1" TargetType="{x:Type TabControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid x:Name="grid" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="0"/>
</Grid.RowDefinitions>
<StackPanel IsItemsHost="True"/>
<Grid x:Name="ContentPanel" Grid.Column="1">
<ContentPresenter x:Name="Compact" Opacity="1" ContentSource="SelectedContent" VerticalAlignment="Top">
<ContentPresenter.LayoutTransform>
<ScaleTransform ScaleY="1" />
</ContentPresenter.LayoutTransform>
</ContentPresenter>
<ContentPresenter x:Name="Details" Opacity="0" ContentSource="SelectedContent" VerticalAlignment="Top">
<ContentPresenter.LayoutTransform>
<ScaleTransform ScaleY="0" />
</ContentPresenter.LayoutTransform>
</ContentPresenter>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup Name="SelectionStates">
<VisualState Name="Unselected">
<Storyboard SpeedRatio="2">
<DoubleAnimation To="1" Storyboard.TargetName="Compact" Storyboard.TargetProperty="Opacity" />
<DoubleAnimation To="1" Storyboard.TargetName="Compact" Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" />
<DoubleAnimation To="0" Storyboard.TargetName="Details" Storyboard.TargetProperty="Opacity" />
<DoubleAnimation To="0" Storyboard.TargetName="Details" Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" />
</Storyboard>
</VisualState>
<VisualState Name="Selected">
<Storyboard SpeedRatio="2">
<DoubleAnimation To="0" Storyboard.TargetName="Compact" Storyboard.TargetProperty="Opacity" />
<DoubleAnimation To="0" Storyboard.TargetName="Compact" Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" />
<DoubleAnimation To="1" Storyboard.TargetName="Details" Storyboard.TargetProperty="Opacity" />
<DoubleAnimation To="1" Storyboard.TargetName="Details" Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleY)" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

How to wrap text in Silverlight DataGridTextColumn

I am trying to create a simple DataGrid in Silverlight 4 Beta but cannot seem to figure out how to get my Note column to wordwrap.
The table represents notes made on an order, so they will be of variable length. i want the 'Note' cell to expand vertically to fit the contents.
I've found numerous similar questions but no answer. Is there something new in Silverlight 4 that will address this?
<data:DataGrid AutoGenerateColumns="False" Name="dataGrid1" IsReadOnly="True">
<data:DataGrid.Columns>
<data:DataGridTextColumn Header="Date" Binding="{Binding Date}" />
<data:DataGridTextColumn Header="User" Binding="{Binding User}" />
<data:DataGridTextColumn Header="Note" Binding="{Binding Note}" />
</data:DataGrid.Columns>
</data:DataGrid>
Use a DataGridTemplateColumn instead of a text column. Have a TextBlock in there with it's TextWrapping set to true:
<data:DataGrid x:Name="LayoutRoot" AutoGenerateColumns="False" IsReadOnly="True" RowDetailsVisibilityMode="Visible" >
<data:DataGrid.Columns>
<data:DataGridTextColumn Header="Date" Binding="{Binding Date}" />
<data:DataGridTextColumn Header="User" Binding="{Binding User}" />
<data:DataGridTemplateColumn Header="Note" Width="100">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding Note}" />
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
</data:DataGrid.Columns>
</data:DataGrid>
I use ElementStyle to set the wrap text,and it works all right. Happy coding!
<Style x:Key="DataGridTextColumnStyle" TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
<data:DataGridTextColumn Binding="{Binding DESC}"
Header="Short Description"
HeaderStyle="{StaticResource DataGridHeaderStyle}"
ElementStyle="{StaticResource DataGridTextColumnStyle}" >
</data:DataGridTextColumn>
Either of the other solutions work - but they both cause a scrolling problem.
If you have a DataGrid that does not have RowHeight set, then the row height will be determined by the size of these TextBlocks. Well, the DataGrid uses virtualization and doesn't draw the TextBlocks until they are displayed. So it simply does not know how big the scrollbar should be. Scrolling with the middle mouse button then causes all sorts of unfortunate behavior.
I'm using paging on my datagrid so I'm disabling virtualization by setting the DataGrid's Style to this:
xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
xmlns:SystemWindowsControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows">
<UserControl.Resources>
<Style x:Key="DataGridStyleNoVirtualization" TargetType="SystemWindowsControls:DataGrid">
<Setter Property="RowBackground" Value="#AAEAEFF4" />
<Setter Property="AlternatingRowBackground" Value="#00FFFFFF" />
<Setter Property="Background" Value="#FFFFFFFF" />
<Setter Property="HeadersVisibility" Value="Column" />
<Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="SelectionMode" Value="Extended" />
<Setter Property="CanUserReorderColumns" Value="True" />
<Setter Property="CanUserResizeColumns" Value="True" />
<Setter Property="CanUserSortColumns" Value="True" />
<Setter Property="AutoGenerateColumns" Value="True" />
<Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected" />
<Setter Property="BorderBrush">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFA3AEB9" Offset="0"/>
<GradientStop Color="#FF8399A9" Offset="0.375"/>
<GradientStop Color="#FF718597" Offset="0.375"/>
<GradientStop Color="#FF617584" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="1" />
<Setter Property="DragIndicatorStyle">
<Setter.Value>
<!-- TODO: Change the TargetType to Control when the fix Jolt bugs 18719 is verified -->
<Style TargetType="ContentControl">
<Setter Property="Foreground" Value="#7FFFFFFF" />
<Setter Property="Template">
<Setter.Value>
<!-- TODO: Change the TargetType to Control when the fix Jolt bugs 18719 is verified -->
<ControlTemplate TargetType="ContentControl">
<Grid>
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="SortStates">
<vsm:VisualState x:Name="Unsorted" />
<vsm:VisualState x:Name="SortAscending">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity" Duration="0" To="1.0"/>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="SortDescending">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity" Duration="0" To="1.0"/>
<DoubleAnimation Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="(RenderTransform).ScaleY" Duration="0" To="-.9"/>
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>
<Rectangle x:Name="BackgroundRectangle" Stretch="Fill" Fill="#66808080" Grid.ColumnSpan="2" />
<Rectangle x:Name="BackgroundGradient" Stretch="Fill" Grid.ColumnSpan="2" Opacity="0" >
<Rectangle.Fill>
<LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
<GradientStop Color="#FFFFFFFF" Offset="0.015" />
<GradientStop Color="#F9FFFFFF" Offset="0.375" />
<GradientStop Color="#E5FFFFFF" Offset="0.6" />
<GradientStop Color="#C6FFFFFF" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter Content="{TemplateBinding Content}"/>
<Path Grid.Column="1" Name="SortIcon" Fill="#7FFFFFFF" RenderTransformOrigin=".5,.5" HorizontalAlignment="Left" VerticalAlignment="Center" Opacity="0" Stretch="Uniform" Width="8" Margin="4,0,0,0" Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z ">
<Path.RenderTransform>
<ScaleTransform ScaleX=".9" ScaleY=".9" />
</Path.RenderTransform>
</Path>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="DropLocationIndicatorStyle">
<Setter.Value>
<Style TargetType="ContentControl">
<Setter Property="Background" Value="#FF3F4346"/>
<Setter Property="Width" Value="2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContentControl">
<Rectangle Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="GridLinesVisibility" Value="Vertical" />
<Setter Property="HorizontalGridLinesBrush" Value="#FFC9CACA" />
<Setter Property="IsTabStop" Value="True" />
<Setter Property="VerticalGridLinesBrush" Value="#FFC9CACA" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="SystemWindowsControls:DataGrid">
<Grid>
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualState x:Name="Normal"/>
<vsm:VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/>
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="2">
<Grid Name="Root" Background="{TemplateBinding Background}">
<Grid.Resources>
<!--Start: TopLeftHeaderTemplate-->
<ControlTemplate x:Key="TopLeftHeaderTemplate" TargetType="dataprimitives:DataGridColumnHeader">
<Grid Name="Root">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border BorderThickness="0,0,1,0" BorderBrush="#FFC9CACA" Background="#FF1F3B53" Grid.RowSpan="2">
<Rectangle Stretch="Fill" StrokeThickness="1">
<Rectangle.Fill>
<LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
<GradientStop Color="#FCFFFFFF" Offset="0.015" />
<GradientStop Color="#F7FFFFFF" Offset="0.375" />
<GradientStop Color="#E5FFFFFF" Offset="0.6" />
<GradientStop Color="#D1FFFFFF" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Border>
<Rectangle VerticalAlignment="Bottom" Width="Auto" StrokeThickness="1" Height="1" Fill="#FFDBDCDC" Grid.RowSpan="2"/>
</Grid>
</ControlTemplate>
<!--End: TopLeftHeaderTemplate-->
<!--Start: TopRightHeaderTemplate-->
<ControlTemplate x:Key="TopRightHeaderTemplate" TargetType="dataprimitives:DataGridColumnHeader">
<Grid Name="RootElement">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border BorderThickness="1,0,0,0" BorderBrush="#FFC9CACA" Background="#FF1F3B53" Grid.RowSpan="2">
<Rectangle Stretch="Fill">
<Rectangle.Fill>
<LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
<GradientStop Color="#FCFFFFFF" Offset="0.015" />
<GradientStop Color="#F7FFFFFF" Offset="0.375" />
<GradientStop Color="#E5FFFFFF" Offset="0.6" />
<GradientStop Color="#D1FFFFFF" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Border>
</Grid>
</ControlTemplate>
<!--End: TopRightHeaderTemplate-->
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<dataprimitives:DataGridColumnHeader Name="TopLeftCornerHeader" Template="{StaticResource TopLeftHeaderTemplate}" Width="22" />
<dataprimitives:DataGridColumnHeadersPresenter Name="ColumnHeadersPresenter" Grid.Column="1"/>
<dataprimitives:DataGridColumnHeader Name="TopRightCornerHeader" Grid.Column="2" Template="{StaticResource TopRightHeaderTemplate}" />
<Rectangle Name="ColumnHeadersAndRowsSeparator" Grid.ColumnSpan="3" VerticalAlignment="Bottom" Width="Auto" StrokeThickness="1" Height="1" Fill="#FFC9CACA"/>
<ScrollViewer Grid.ColumnSpan="2" Grid.Row="1">
<dataprimitives:DataGridRowsPresenter Name="RowsPresenter" />
</ScrollViewer>
<Rectangle Name="BottomRightCorner" Fill="#FFE9EEF4" Grid.Column="2" Grid.Row="2" />
<Rectangle Name="BottomLeftCorner" Fill="#FFE9EEF4" Grid.Row="2" Grid.ColumnSpan="2" />
<Grid Grid.Column="1" Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Rectangle Name="FrozenColumnScrollBarSpacer" />
</Grid>
</Grid>
</Border>
<Border x:Name="DisabledVisualElement" IsHitTestVisible="False" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" CornerRadius="2" Background="#8CFFFFFF" Opacity="0"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
To resolve scrolling issue you can just strongly set the Height property of TextBlock, for example:
<Style x:Key="DataGridTextColumnStyle" TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Height" Value="15"/>
</Style>

Resources