I'm interested in finding some way to make a gridline dotted for relevant xamWebChart types. Thank you in advance for your time.
Hello willmiller,
Please take a look at this forum post. It sounds like the same thing you're trying to accomplish. If it's not, I can pass your question onto a developer.
Elizabeth AlbertLocalization Engineer
Thank you for your help, Elizabeth. I believe that this is probably the answer I need, but I'm having difficulty translating it from VB. Are you able to help me with that? Thanks again!
Hello,
I used this code converter! :) I pasted the code below. Let me know if there's anything else.
// First line might not be necessary // or should change?using Microsoft.VisualBasic; using System;using System.Collections;using System.Collections.Generic;using System.Data;using System.Diagnostics;public partial class MainPage : UserControl{ public MainPage() { InitializeComponent(); }}public class BoundsRectangle : Panel{ public static DependencyProperty PathDataProperty = DependencyProperty.Register("PathData", typeof(GeometryGroup), typeof(BoundsRectangle), new PropertyMetadata(PathDataPropertyChanged)); public BoundsRectangle() { this.SizeChanged += OnSizeChanged; } public GeometryGroup PathData { get { return (GeometryGroup)GetValue(PathDataProperty); } set { SetValue(PathDataProperty, value); } } private void OnSizeChanged(object sender, SizeChangedEventArgs args) { double newWidth = args.NewSize.Width; GeometryGroup newData = new GeometryGroup(); LineGeometry top = new LineGeometry(); top.StartPoint = new Point(0, 0); top.EndPoint = new Point(newWidth, 0); newData.Children.Add(top); PathData = newData; } private static void PathDataPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { }}public class DoublingConverter : IValueConverter{ public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null && value is double) { return value * 2.0; } return null; } public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); }}
Hello again,
When I attempt to implement this code verbatim, I see no change in my chart gridlines. The only change I had to make was converting the igChart reference to igWebChart in the xaml. If you have any insight into why this might be the case, I would greatly appreciate it. Thanks again!
Hi,
Are you saying that the xaml you copied started working when you changed igChart to igWebChart? This is probably just because that is how you have the prefix defined for XamWebChart's assembly in your xaml file.
In the root element of the file you can see where you have all your xaml namespaces defined. They will all look something like this:
xmlns:PREFIX="clr-namespace:SOME_NAMESPACE;assembly=SOME_ASSEMBLY"
or
xmlns:PREFIX="SOME_URI"
where PREFIX is a prefix that you will use to refer to that namespace further down in the file, SOME_NAMESPACE represents a CLR namespace in which the types you want to refer to are defined, and SOME_ASSEMBLY is the assembly that contains them. Alternatively if a library has defined a URI by which it can be referred, you can specify that as SOME_URI.
So, in the top of your file, you likely have something like this:
xmlns:igWebChart="MAPPING"
where MAPPING identifies how to find our XamWebChart control. Meanwhile in the linked sample you will see:
xmlns:igChart="MAPPING"
where MAPPING identifies how to find our XamWebChart control. So to use the linked sample xaml you just needed to update your xaml prefix to match the prefixes you had defined in your xaml file.
If you want more information about how Xaml namespace prefixes are defined, see: http://msdn.microsoft.com/en-us/library/cc189061(v=vs.95).aspx
Let me know if you have more questions. Hope this helps!
-Graham
I'm sorry, I should probably be more clear - my gridlines don't appear dotted no matter what I try with this approach. The xamChart to xamWebChart is just the only modification I made after copying and pasting. I receive no errors, and the gridlines just display as normal.
Hmm... works for me...
Are you sure you are assigning the grid line style?
<igChart:Axis.MajorGridline> <igChart:GridlineGroup Stroke="Red" StrokeThickness="3" GridlineStyle="{StaticResource LineStyle}" /> </igChart:Axis.MajorGridline>
Here is the full code of my sample in c#:
The xaml:
<UserControl x:Class="SilverlightApplication109.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:igChart="clr-namespace:Infragistics.Silverlight.Chart;assembly=InfragisticsSL4.Controls.Charts.XamWebChart.v10.3" xmlns:local="clr-namespace:SilverlightApplication109" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <UserControl.Resources> <Style x:Key="LineStyle" TargetType="igChart:Mark"> <Setter Property="StrokeThickness" Value=".5"/> <Setter Property="Stroke" Value="#FFE6EFF7"/> <Setter Property="Fill" Value="#FFE6EFF7"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="igChart:Mark"> <Grid x:Name="parentGrid"> <Grid.Resources> <local:DoublingConverter x:Key="DoublingConverter"/> </Grid.Resources> <local:BoundsRectangle x:Name="Bounds" /> <Path UseLayoutRounding="True" Stroke="{TemplateBinding Stroke}" StrokeThickness="{Binding Path=StrokeThickness, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource DoublingConverter}}" StrokeDashArray="3" Data="{Binding ElementName=Bounds, Path=PathData, Mode=OneWay}"> </Path> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources> <Grid x:Name="LayoutRoot"> <igChart:XamWebChart> <igChart:XamWebChart.Axes> <igChart:Axis AxisType="PrimaryY"> <igChart:Axis.MajorGridline> <igChart:GridlineGroup Stroke="Red" StrokeThickness="3" GridlineStyle="{StaticResource LineStyle}" /> </igChart:Axis.MajorGridline> </igChart:Axis> </igChart:XamWebChart.Axes> <igChart:XamWebChart.Series> <igChart:Series> <igChart:Series.DataPoints> <igChart:DataPoint Value="1" /> <igChart:DataPoint Value="2" /> <igChart:DataPoint Value="3" /> <igChart:DataPoint Value="4" /> <igChart:DataPoint Value="5" /> </igChart:Series.DataPoints> </igChart:Series> </igChart:XamWebChart.Series> </igChart:XamWebChart> </Grid> </UserControl>
And the code behind:
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Media; namespace SilverlightApplication109 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } } public class BoundsRectangle : Panel { public static DependencyProperty PathDataProperty = DependencyProperty.Register( "PathData", typeof(GeometryGroup), typeof(BoundsRectangle), new PropertyMetadata(PathDataPropertyChanged)); public BoundsRectangle() { this.SizeChanged += OnSizeChanged; } public GeometryGroup PathData { get { return (GeometryGroup)GetValue(PathDataProperty); } set { SetValue(PathDataProperty, value); } } private void OnSizeChanged( object sender, SizeChangedEventArgs args) { double newWidth = args.NewSize.Width; GeometryGroup newData = new GeometryGroup(); LineGeometry top = new LineGeometry(); top.StartPoint = new Point(0, 0); top.EndPoint = new Point(newWidth, 0); newData.Children.Add(top); PathData = newData; } private static void PathDataPropertyChanged( DependencyObject sender, DependencyPropertyChangedEventArgs args) { } } public class DoublingConverter : IValueConverter { public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null && value is double) { return (double)value * 2.0; } return null; } public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } }
Thank you Graham! I'm not sure what the difference was between your code and mine, but everything works now.