如何在WPF ResourceDictionary中有条件地定义资源?

时间:2018-07-07 06:57:31

标签: wpf resources

我有以下资源字典:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<!--<Color x:Key="Control.Disabled.Background">#F0F0F0</Color>
<Color x:Key="ItemsContainer.SelectedItemColor">#F58220</Color>
<Color x:Key="NBBR.DarkBackground">#08305B</Color>
<Color x:Key="NBBR.LightBackground">#93B8E1</Color>
<Color x:Key="NBBR.MediumDarkBackground">#004283</Color>
<Color x:Key="NBBR.DataRow.DarkBackground">#EBF0F4</Color>
<Color x:Key="NBBR.DataRow.LightBackground">#FFFFFF</Color>-->

<Color x:Key="Control.Disabled.Background">#F0F0F0</Color>
<Color x:Key="ItemsContainer.SelectedItemColor">#F58220</Color>
<Color x:Key="NBBR.DarkBackground">DarkGreen</Color>
<Color x:Key="NBBR.LightBackground">LightGreen</Color>
<Color x:Key="NBBR.MediumDarkBackground">Green</Color>
<Color x:Key="NBBR.DataRow.DarkBackground">#EBF0F4</Color>
<Color x:Key="NBBR.DataRow.LightBackground">#FFFFFF</Color>

当前,我必须手动注释和取消注释为应用程序设置不同颜色的块。但是我想要一个#If …. #Then …. #Else … #Endif类似的构造,它依赖于编译常量。

我该怎么做?

0 个答案:

没有答案