Jump to content
Software FX Community

AKhristenko

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by AKhristenko

  1. That's briefly how we are doing it. In your view:

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

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:vm="clr-namespace:your-viewmodel-project-here">

    <DataTemplate DataType="{x:Type vm:ChartWidgetViewModel}">

      <ContentControl Name="ChartWidgetViewModelContent" Template="{DynamicResource ViewModelLoadingTemplate}" />

    </DataTemplate>

     

    <ControlTemplate TargetType="{x:Type ContentControl}" x:Key="ChartWidgetViewContentTemplate">

    <Grid>

    <cfx:Chart>

     </cfx:Chart>

    </Grid>

    Then you can declare your VM class:

    public class ChartWidgetViewModel

  2. 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.

  3. 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:

    ...

    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.

×
×
  • Create New...