Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Theming using resources without Blend vomitting

WPF is great in that I should be able to use {StaticResource MyBackground} instead of "White" throughout my app, and then by changing resource definitions redefine the look of my entire application.

Problem is Expression Blend just won't work if you have references to global resources in a subcontrol. Is there any other way of theme-ing your app? I am not willing to lose Blend designer support, or replicate a piece of code/xaml in every single control. I find it astounding that they have not fixed a bug of this magnitude.

Any ideas?

Cheers

like image 655
Jamona Mican Avatar asked May 21 '26 20:05

Jamona Mican


1 Answers

So I haven't tried this, but it sounds like it would work. Also, the information is a bit dated. Please do let me know if it solves the problem. :)

From the Blend blog, add the following two chunks to your project files:

<DesignTime Condition="'$(SolutionPath)'!='' AND Exists('$(SolutionPath)')">true</DesignTime>

…. 
<ApplicationDefinition Condition="'$(DesignTime)'=='true' AND '$(BuildingInsideVisualStudio)'!='true' AND '$(BuildingInsideExpressionBlend)'!='true'" Include="App.xaml"> 
      <Generator>MSBuild:Compile</Generator> 
      <SubType>Designer</SubType> 
</ApplicationDefinition>

Basically this includes your app.xaml conditionally into your project so it gets used at design time, but not at build time. I'm guessing they assume people use msbuild to produce production code rather than clicking the build compile button.

like image 166
Mike Post Avatar answered May 23 '26 20:05

Mike Post