开发者

Binding fill to color resource conditionally

I am trying to bind the fill of a rectangle to a color in a resource dictionary. In blend it is very easy to bind to one color.

But in my viewmodel I have an enum with 3 'categories' and I would like the rectangles fill to be different based on the value of this enum, and keep all the colors in the resource dictionary.

Has anyone tried doing this? Would it be a bindin开发者_StackOverflow社区g converter that does enum -> color resource?

Solved: Accessing colors in a resource dictionary from a value converter


Your converter can return a SolidColorBrush. You can instantiate it using from a color in the resource dictionary like this for example.

SolidColorBrush b = (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜