Change the color of the ResizeGrip in WPF
c#, wpf, xaml
Solution
If we go check out the default template we see not only are those properties not template bound, they have a hard set "Transparent" in there. So we can just take up the slack;
EDIT
<Style x:Key="blah" TargetType="{x:Type ResizeGrip}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ResizeGrip}">
<Border Background="{TemplateBinding Background}"
SnapsToDevicePixels="True"
Width="10"
Height="10">
<Path Data="M7.677,7.5300003 L9.677,7.5300003 9.677,9.5300002 7.677,9.5300002 z M3.786,7.5300003 L5.7859998,7.5300003 5.7859998,9.5300002 3.786,9.5300002 z M0,7.5300003 L2,7.5300003 2,9.5300002 0,9.5300002 z M3.786,3.8280003 L5.7859998,3.8280003 5.7859998,5.8280003 3.786,5.8280003 z M7.677,3.7660003 L9.677,3.7660003 9.677,5.7659999 7.677,5.7659999 z M7.677,0 L9.677,0 9.677,2 7.677,2 z" Fill="{TemplateBinding Foreground}" Height="9.53" Stretch="Fill" VerticalAlignment="Top" Width="9.677"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Now you can go make it whatever you want;
<ResizeGrip Foreground="Red" Style="{StaticResource blah}"/>
Hope this helps, cheers.
Problem
I want to change the color of the `ResizeGrip`'s squares, but I can't find the right property. I tried overriding the default ResizeGrip style as follow: ``` <Style TargetType="{x:Type ResizeGrip}"> <Setter Property="Foreground" Value="{StaticResource WindowBackground}" /> </Style> ``` I suppose the ControlTemplate is too complex to be able to reach that property from the TemplatedParent. So, am I supposed to override the ControlTemplate ? Get the grip by code ? Or is there something easier that I missed ?