Apply Theme at Runtime Using Dynamic Expression
In This Topic
This topic explains how to apply a theme at runtime by using a dynamic expression so that the applied theme depends on the parameter’s value.
Consider a sample report 'PurchaseReport.rdlx' which can be downloaded from
GitHub: ..\Samples18\DesignerPro\ReportsGallery\Reports\Page Report\Other.
Add Parameter for User Input
- Open 'PurchaseReport.rdlx' report.
- From the Report Explorer, right-click the Parameters node and select Add Parameter.
- In the General tab of the Report - Parameters dialog, specify the following:
- Name: ThemeParameter
- Data type: String
- Text for prompting users for a value: Select a Theme
- Go to the Available Values tab, select Non-queried option and add two themes with Label and Value settings as follows:
- Click OK.
Add Theme to the Report
- Select the Report menu and click open the Report Properties.
- Go to the Themes page and add a theme with expression:
=Parameters!ThemeParameter.Value
Apply Theme to Report Controls
- Lets us apply themes to the table header and detail row. First, select the Header row of the table, and set following properties:
- Color: =Theme.Colors!Dark1
- Font > FontStyle: =Theme.Fonts!MajorFont.Style
- Font > FontFamily: =Theme.Fonts!MajorFont.Family
- Font > FontSize: =Theme.Fonts!MajorFont.Size
- Font > FontWeight: =Theme.Fonts!MajorFont.Weight
- Select the Detail row of the table and set the following properties:
- Color: =Theme.Colors!Light1
- Font > FontStyle: =Theme.Fonts!MinorFont.Style
- Font > FontFamily: =Theme.Fonts!MinorFont.Family
- Font > FontSize: =Theme.Fonts!MinorFont.Size
- Font > FontWeight: =Theme.Fonts!MinorFont.Weight
- Select all the text boxes below the table and set the BackgroundColor property to =Theme.Colors!Light1
- Preview the report and select any one of the two themes and click View Report to view the theme applied to the report.
Note: Since the report needs to be re-rendered for theme to apply, on preview, you can not change the theme of the report by changing the theme selection from the report parameter. The report prompts for the report parameter for the first time and shows the result on clicking View Report, however there is no change in the applied theme if you change the theme and click View Report, unless there are updates in report that causes report to re-render.
See Also