By editing the default template of the datagrid this problem can be solved.
<style targettype="{x:Type my:DataGrid}">
<setter property="Background" value="Black" />
<setter property="Template">
<setter.value>
<controltemplate targettype="{x:Type my:DataGrid}">
<border removed="{TemplateBinding Background}">
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True"
Padding="{TemplateBinding Padding}">
<scrollviewer focusable="false">
Name="DG_ScrollViewer">
<scrollviewer.template>
<controltemplate targettype="{x:Type ScrollViewer}">
<grid>
<grid.rowdefinitions>
<rowdefinition height="Auto" />
<rowdefinition height="*" />
<rowdefinition height="Auto" />
</grid.rowdefinitions>
<grid.columndefinitions>
<columndefinition width="Auto" />
<columndefinition width="*" />
<columndefinition width="Auto" />
</grid.columndefinitions>
<button command="{x:Static my:DataGrid.SelectAllCommand}">
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:DataGrid}}, Path=CellsPanelHorizontalOffset}"
Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type my:DataGrid}, ResourceId=DataGridSelectAllButtonStyle}}"
Focusable="false"
Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:DataGrid}}, Path=HeadersVisibility, Converter={x:Static my:DataGrid.HeadersVisibilityConverter}, ConverterParameter={x:Static my:DataGridHeadersVisibility.All}}" />
<my:datagridcolumnheaderspresenter grid.column="1" xmlns:my="#unknown">
Name="PART_ColumnHeadersPresenter"
Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:DataGrid}}, Path=HeadersVisibility, Converter={x:Static my:DataGrid.HeadersVisibilityConverter}, ConverterParameter={x:Static my:DataGridHeadersVisibility.Column}}"/>
<scrollcontentpresenter x:name="PART_ScrollContentPresenter" grid.row="1" grid.columnspan="2" cancontentscroll="{TemplateBinding CanContentScroll}" xmlns:x="#unknown" />
<scrollbar grid.row="1" grid.column="1" name="PART_VerticalScrollBar">
Orientation="Vertical" HorizontalAlignment="Right" Margin="0,0,0,0" SnapsToDevicePixels="True" OverridesDefaultStyle="True"
Maximum="{TemplateBinding ScrollableHeight}"
ViewportSize="{TemplateBinding ViewportHeight}"
Value="{Binding Path=VerticalOffset, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}">
<scrollbar.style>
<style targettype="{x:Type ScrollBar}">
<setter property="SnapsToDevicePixels" value="True" />
<setter property="OverridesDefaultStyle" value="true" />
<style.triggers>
<trigger property="Orientation" value="Vertical">
<setter property="Width" value="18" />
<setter property="Height" value="Auto" />
<setter property="Template" value="{StaticResource VerticalScrollBar}" />
</trigger>
</style.triggers>
</style>
</scrollbar.style>
</scrollbar>
<grid grid.row="2" grid.column="1">
<grid.columndefinitions>
<columndefinition width="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:DataGrid}}, Path=NonFrozenColumnsViewportHorizontalOffset}" />
<columndefinition width="*" />
</grid.columndefinitions>
<scrollbar grid.column="1">
Name="PART_HorizontalScrollBar"
Orientation="Horizontal"
Maximum="{TemplateBinding ScrollableWidth}"
ViewportSize="{TemplateBinding ViewportWidth}"
Value="{Binding Path=HorizontalOffset, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}">
<scrollbar.style>
<style targettype="{x:Type ScrollBar}">
<setter property="SnapsToDevicePixels" value="True" />
<setter property="OverridesDefaultStyle" value="true" />
<style.triggers>
<trigger property="Orientation" value="Horizontal">
<setter property="Width" value="Auto" />
<setter property="Height" value="18" />
<setter property="Template" value="{StaticResource HorizontalScrollBar}" />
</trigger>
</style.triggers>
</style>
</scrollbar.style>
</scrollbar>
</grid>
</my:datagridcolumnheaderspresenter></button></grid>
</controltemplate>
</scrollviewer.template>
<itemspresenter snapstodevicepixels="{TemplateBinding SnapsToDevicePixels}" />
</scrollviewer>
</border>
</controltemplate>
</setter.value>
</setter>
</style>
in the xaml code that i given,
PART_VerticalScrollBar is scrollbar.
i have altered the grid.column = 2 to grid.column = 1.
Happy codeing