1

Topic: [WPF, Binding] conversion enum in a window resource

In WPF experience practically a zero also it did not turn out  the decision. It is necessary: on the basis of value enum to draw a graded-index ellipse of appropriate color Let will be: public enum MyState {Success, Warning, Error} resources are registered in a window: <Window. Resources> <RadialGradientBrush x:Key = "yellowBrush"> <GradientStop Color = "LightYellow"> </GradientStop> <GradientStop Color = "Yellow" Offset = "1"> </GradientStop> </RadialGradientBrush> <RadialGradientBrush x:Key = "greenBrush"> <GradientStop Color = "LightGreen"> </GradientStop> <GradientStop Color = "Green" Offset = "1"> </GradientStop> </RadialGradientBrush> <RadialGradientBrush x:Key = "redBrush"> <GradientStop Color = "Red"> </GradientStop> <GradientStop Color = "#8B0000" Offset = "1"> </GradientStop> </RadialGradientBrush> </Window. Resources> further it is necessary Ellipse with appropriate filling: <Ellipse Height = "50" Width = "50" Fill = "{Binding Path=State...}"/> property State of a context, accordingly, has type MyState. If to write the converter from MyState in Brush it is not clear as to get access to a window resource. If to do the converter not in Brush, and at line with a resource key it is not clear as then a resource on a key it is possible to fasten (ResourceKey not ).

2

Re: [WPF, Binding] conversion enum in a window resource

Hello, karbofos42, you wrote: K> In WPF experience practically a zero also it did not turn out  the decision. K> it is necessary: on the basis of value enum to draw a graded-index ellipse of appropriate color K> Let will be: K> K> public enum MyState K> {K> Success, K> Warning, K> Error K>} K> K> resources are registered in a window: K> K> <Window. Resources> K> <RadialGradientBrush x:Key = "yellowBrush"> K> <GradientStop Color = "LightYellow"> </GradientStop> K> <GradientStop Color = "Yellow" Offset = "1"> </GradientStop> K> </RadialGradientBrush> K> <RadialGradientBrush x:Key = "greenBrush"> K> <GradientStop Color = "LightGreen"> </GradientStop> K> <GradientStop Color = "Green" Offset = "1"> </GradientStop> K> </RadialGradientBrush> K> <RadialGradientBrush x:Key = "redBrush"> K> <GradientStop Color = "Red"> </GradientStop> K> <GradientStop Color = "#8B0000" Offset = "1"> </GradientStop> K> </RadialGradientBrush> K> </Window. Resources> K> K> further it is necessary Ellipse with appropriate filling: K> K> <Ellipse Height = "50" Width = "50" Fill = "{Binding Path=State...} "/> K> K> property State of a context, accordingly, has type MyState. K> If to write the converter from MyState in Brush it is not clear as to get access to a window resource. If to do the converter not in Brush, and at line with a resource key it is not clear as then a resource on a key it is possible to fasten (ResourceKey not ). Let the converter returns at once the ready image for  Image (property source) which takes from resources. Here it is elementary, in a picture folder threw, and from there then you get.

3

Re: [WPF, Binding] conversion enum in a window resource

Hello, karbofos42, you wrote: K> It is necessary: on the basis of value enum to draw a graded-index ellipse of appropriate color Enum driving a Visual State change via the ViewModel... <<RSDN@Home 1.3.110 alpha 5 rev. 62>>

4

Re: [WPF, Binding] conversion enum in a window resource

1. As a variant, it is possible here Fill = "{Binding Path=State...}"  not to State, and it is for example immediate to a window. Then in the converter it will be possible from DataContext to receive State, and from a window resources. 2. Other variant - the converter with properties. I.e. directly in a converter class to declare or three properties with , or one property of type Resources, and these  to add there that the converter knew where them to search. That above, should work on all xaml platforms. If it is necessary for you only WPF,  MultiBinding and IMultiValueConverter

5

Re: [WPF, Binding] conversion enum in a window resource

Hello, notacat, you wrote: N> 1. As a variant, it is possible here Fill = "{Binding Path=State...}"  not to State, and it is for example immediate to a window. N> then in the converter it will be possible from DataContext to receive State, and from a window resources. N> 2. Other variant - the converter with properties. I.e. directly in a converter class to declare or three properties with , or one property of type Resources, and these  to add there that the converter knew where them to search. N> that above, should work on all xaml platforms. N> if it is necessary for you only WPF  MultiBinding and IMultiValueConverter I Thank for . I blunted Something and did not think that it is possible for the property converter to add

6

Re: [WPF, Binding] conversion enum in a window resource

self-made here such converter. https://documentation.devexpress.com/WP … tConverter