Jump to content
Software FX Community

ConditionalAttributes not working in DataTemplate


justin.katz

Recommended Posts

I've encountered a problem where a ConditionalAttribute on my Chart works fine when the Chart is defined in the normal body of the Xaml.  The ConditionalAttributes are completely ignored when used on a Chart defined in a DataTemplate though.  Working and non-working examples are shown below, and suggestions would be appreciated.

 

<Window x:Class="ChartFXSandbox.Window1"   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   xmlns:cfx="clr-namespace:ChartFX.WPF;assembly=ChartFX.WPF"   Title="ChartFXSandbox" Height="800" Width="1024"   >  <Window.Resources>   <XmlDataProvider x:Key="ChartData" XPath="/Coordinates/Coordinate">   <x:XData>   <Coordinates xmlns="">   <Coordinate>   <Domain>1</Domain>   <Range>2</Range>   </Coordinate>   <Coordinate>   <Domain>2</Domain>   <Range>4</Range>   </Coordinate>   <Coordinate>   <Domain>3</Domain>   <Range>6</Range>   </Coordinate>   <Coordinate>   <Domain>4</Domain>   <Range>8</Range>   </Coordinate>   <Coordinate>   <Domain>5</Domain>   <Range>10</Range>   </Coordinate>   </Coordinates>   </x:XData>   </XmlDataProvider>

  <DataTemplate x:Key="ChartDataTemplate" DataType="ChartData">   <cfx:Chart ItemsSource="{Binding Source={StaticResource ChartData}}" Gallery="Line">   <cfx:SeriesAttributes BindingPath="Range" BindingPathX="Domain"/>   <cfx:Chart.ConditionalAttributes>   <cfx:ConditionalAttributes Fill="Blue">   <cfx:ConditionalAttributes.Condition>   <cfx:RangeCondition From="3" To="9" BindingPath="Range"/>   </cfx:ConditionalAttributes.Condition>   </cfx:ConditionalAttributes>   </cfx:Chart.ConditionalAttributes>     </cfx:Chart>   </DataTemplate>     </Window.Resources>

  <Grid>   <Grid.RowDefinitions>   <RowDefinition/>   <RowDefinition/>   </Grid.RowDefinitions>   <ContentControl Grid.Row="0" Content="{Binding Source={StaticResource ChartData}}" ContentTemplate="{StaticResource ChartDataTemplate}" />     <ContentControl Grid.Row="1">   <cfx:Chart ItemsSource="{Binding Source={StaticResource ChartData}}" Gallery="Line">   <cfx:SeriesAttributes BindingPath="Range" BindingPathX="Domain"/>   <cfx:Chart.ConditionalAttributes>   <cfx:ConditionalAttributes Fill="Blue">   <cfx:ConditionalAttributes.Condition>   <cfx:RangeCondition From="3" To="9" BindingPath="Range"/>   </cfx:ConditionalAttributes.Condition>   </cfx:ConditionalAttributes>   </cfx:Chart.ConditionalAttributes>   </cfx:Chart>   </ContentControl>  </Grid></Window>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...