qoiu thegreat

qoiu thegreat

  • NA
  • 3
  • 2.9k

Showing image for datapoints in Scatter series in Silverlight

Mar 30 2012 1:17 AM

Hi,

   I want to show an image for datapoints (same image for each data point) of the scatter series.the xaml looks like this :
 

     <UserControl.Resources>
        <ImageBrush x:Key="ImageBrushStyle" ImageSource="Images\customImage.png" />
        <Style x:Key="DataPointStyle1" TargetType="DVC:ScatterDataPoint">
            <Setter Property="Background" Value="{StaticResource ImageBrushStyle}"/>         
            <Setter Property="IsTabStop" Value="False"/>           
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="DVC:ScatterDataPoint">                                        
                            <!--<Rectangle Fill="Yellow" Width="100" Height="100"  />-->
                        <Image Source="Images\customImage.png"></Image>                      
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <DVC:Chart Canvas.Top="80" Canvas.Left="10" x:Name="mcChart_CustomSection"
           Width="800" Height="400"
           Background="Gray">
            <DVC:Chart.Series>
                <DVC:ScatterSeries Title=" SampleData"
            IndependentValueBinding="{Binding Path=Key}"
            DependentValueBinding="{Binding Path=Value}">
                </DVC:ScatterSeries>
            </DVC:Chart.Series>
        </DVC:Chart>
    </Grid>
</UserControl>


Then,
The code sets the style in this way :
   ((ScatterSeries)mcChart_CustomSection.Series[0]).ItemsSource =
                new KeyValuePair<int, int>[]{
                    new KeyValuePair<int, int>(1, 140),
                    new KeyValuePair<int, int>(2, 150)                                                
                };

            var ss1 = (ScatterSeries)mcChart_CustomSection.Series[0];
            mcChart_CustomSection.Series.Remove(ss1);
            ss1.DataPointStyle = (Style)this.Resources["DataPointStyle1"];
            mcChart_CustomSection.Series.Add(ss1);
          

But, it does not work.(The points are not plotted).

Is it possible to show image there(Images\customImage.png)?


Thanks.


Answers (1)