Sorry, formatting got screwed up. Here it is again
Dear Forum,
I am trying to solve a task of showing negative values in red only when the chart is of type Bar or Gantt. There is no code-behind and same View and View model are used for all charts.
Currently I am trying to make use of conditional attribute and its property Active to switch the colouring on/off when needed. I have a property in my view model like this:
public bool ShowNegativesInRed {
get { return (this.ChartConfig.WidgetType == ChartWidgetTypes.Gantt); }
}
Then in the View I am doing the following:
<cfx:Chart Gallery="{Binding Path=WidgetType, Mode=OneWay}" ...>
<cfx:Chart.ConditionalAttributes>
<cfx:ConditionalAttributes Fill="Red" Stroke="Red">
<cfx:ConditionalAttributes.Condition>
<cfx:RangeCondition To="0" Active="{Binding Path=ShowNegativesInRed}" />
</cfx:ConditionalAttributes.Condition>
</cfx:ConditionalAttributes>
</cfx:Chart.ConditionalAttributes>
...
</cfx:Chart> When I start the app and try to display the chart, "Active" is always resolved to true and I get a binding error:System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=ShowNegativesInRed; DataItem=null; target element is 'RangeCondition' (HashCode=20263529); target property is 'Active' (type 'Boolean')Googling for this error I found someone advising to declare that thing causing the error in a local resource and use it from there, however I cannot think of how to move my cfx:RangeCondition to a local resource.
If anyone has an idea how to do that or maybe an alternative solution for my initial task that would be highly appreciated.