Search code examples
wpfbackground-colorxtrareport

XtraReports DocumentPreviewControl changes frame background color


I'm using trial version of XtraReports. My application is based on frames and materialdesing dialogs. I have created few pages using custom accent colors. All works fine. Bu when I open a dialog or page which contains DocumentPreviewControl and switch back to other page, the background of my pages changed to white. When I remove DocumentPreviewControl from page all works good.

Any suggestions?

Code: ReportPage.xaml:

<StackPanel>
    <DockPanel Height="750" Background="#454545">
        <dxp:DocumentPreviewControl RequestDocumentCreation="True" DocumentSource="{Binding ReportDocument}" dx:ThemeManager.ThemeName="Office2013DarkGray"/>
    </DockPanel>
</StackPanel>

MainWindow.xaml:

<Frame Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" 
           Name="frame"
           Background="#FF454545"
           Margin="0,20,0,10"
           NavigationUIVisibility="Hidden">
            <Frame.Style>
                <Style TargetType="Frame">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsLogged}" Value="True">
                            <Setter Property="Source" Value="MainPage.xaml"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsLogged}" Value="False">
                            <Setter Property="Source" Value="NotLoggedPage.xaml"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Frame.Style>

Solution

  • This behavior occurs since DevExpress themes affect styling of standard controls as well. When a control injects into a visual tree the default Office2016White theme is applied to all elements. If you want to disable this behavior, set the ApplicationThemeHelper.UseLegacyDefaultTheme property to true at the application startup:

    public partial class App : Application {
        public App() {
             ApplicationThemeHelper.UseLegacyDefaultTheme = true;
        }
    }