2010-07-28 45 views

回答

1

我在http://wpf.codeplex.com/SourceControl/list/changesets

我的想法是,下載最新的源代碼通過改變風格不同的圖表系列刪除動畫(圖點,DataPointStyle)

例如爲charting:PieDataPoint

嘗試刪除所示數據的動畫,並使用給定的鍵(x:key =「myStyle」 - >DataPointStyle="{StaticResource myStyle}"

並刪除Opacity="0"<Grid x:Name="Root" Opacity="0">

刪除該可視狀態組來自你的風采

<VisualStateGroup x:Name="RevealStates"> 
    <VisualStateGroup.Transitions> 
     <VisualTransition GeneratedDuration="0:0:0.5" /> 
    </VisualStateGroup.Transitions> 
    <VisualState x:Name="Shown"> 
     <Storyboard> 
      <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1" Duration="0" /> 
     </Storyboard> 
    </VisualState> 
    <VisualState x:Name="Hidden"> 
     <Storyboard> 
      <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0" Duration="0" /> 
     </Storyboard> 
    </VisualState> 
</VisualStateGroup> 

編輯

這是改變的樣式。

<!-- charting:PieDataPoint --> 
<Style TargetType="charting:PieDataPoint"> 
    <Setter Property="Background" Value="Orange" /> 
    <Setter Property="BorderBrush" Value="White" /> 
    <Setter Property="BorderThickness" Value="1" /> 
    <Setter Property="IsTabStop" Value="False" /> 
    <Setter Property="RatioStringFormat" Value="{}{0:p2}" /> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="charting:PieDataPoint"> 
       <Grid x:Name="Root" Opacity="0"> 
        <VisualStateManager.VisualStateGroups> 
         <VisualStateGroup x:Name="CommonStates"> 
          <VisualStateGroup.Transitions> 
           <VisualTransition GeneratedDuration="0:0:0.1" /> 
          </VisualStateGroup.Transitions> 
          <VisualState x:Name="Normal" /> 
          <VisualState x:Name="MouseOver"> 
           <Storyboard> 
            <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" /> 
           </Storyboard> 
          </VisualState> 
         </VisualStateGroup> 
         <VisualStateGroup x:Name="SelectionStates"> 
          <VisualStateGroup.Transitions> 
           <VisualTransition GeneratedDuration="0:0:0.1" /> 
          </VisualStateGroup.Transitions> 
          <VisualState x:Name="Unselected" /> 
          <VisualState x:Name="Selected"> 
           <Storyboard> 
            <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" /> 
           </Storyboard> 
          </VisualState> 
         </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
        <Path x:Name="Slice" Data="{TemplateBinding Geometry}" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeMiterLimit="1"> 
         <ToolTipService.ToolTip> 
          <StackPanel> 
           <ContentControl Content="{TemplateBinding FormattedDependentValue}" /> 
           <ContentControl Content="{TemplateBinding FormattedRatio}" /> 
          </StackPanel> 
         </ToolTipService.ToolTip> 
        </Path> 
        <Path x:Name="SelectionHighlight" Data="{TemplateBinding GeometrySelection}" Fill="Red" StrokeMiterLimit="1" IsHitTestVisible="False" Opacity="0" /> 
        <Path x:Name="MouseOverHighlight" Data="{TemplateBinding GeometryHighlight}" Fill="White" StrokeMiterLimit="1" IsHitTestVisible="False" Opacity="0" /> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

我第一次嘗試刪除動畫後,我想放棄,因爲它沒有奏效。

但後來我用反射器看着我的源代碼,並找到了一種方法,它仍然有效。

設置DataPointStyle不幸是不夠的,我認爲這是一個錯誤。

<chartingToolkit:Chart Margin="8"> 

    <chartingToolkit:Chart.Series> 
    <chartingToolkit:BarSeries x:Name="barSeries" 
           Title="Experience" 
           DataPointStyle="{StaticResource myBarStyle}"> 
    </chartingToolkit:BarSeries> 
    </chartingToolkit:Chart.Series> 

</chartingToolkit:Chart> 

在包含圖表的控件的構造函數中,只需執行以下操作。

this.barSeries.RefreshStyles(); 

希望這有助於