This example demonstrates how to change SVG image colors for a theme.
DevExpress Themes can adapt an SVG image's colors to the application theme. You can create image states that define how to change image colors based on the applied theme:
- Create an image state.
- Specify the
WpfSvgPalette.Key
property to identify the state. - Define a Brush that replaces colors. The
SolidColorBrush.Key
property specifies the color replaced with theSolidColorBrush.Color
property. - Attach the
dx:SvgImageHelper.State
property to the image. This property applies the state based on itsKey
property value.
This example changes the color from #333333 to #FFFFFE if the Office2016Black theme is applied:
<Image Source="{dx:SvgImageSource Uri=Images/logo.svg}" Width="164"
dx:SvgImageHelper.State="{Binding Path=(dx:ThemeManager.TreeWalker).ThemeName, RelativeSource={RelativeSource Self}}">
<dx:WpfSvgPalette.Palette>
<dx:WpfSvgPalette>
<dx:WpfSvgPalette.States>
<dx:WpfSvgPalette x:Key="Office2016Black">
<SolidColorBrush x:Key="#333333" Color="#FFFFFE"/>
</dx:WpfSvgPalette>
</dx:WpfSvgPalette.States>
</dx:WpfSvgPalette>
</dx:WpfSvgPalette.Palette>
</Image>
(you will be redirected to DevExpress.com to submit your response)