Skip to content

Commit 2e9e26a

Browse files
Merge pull request #1 from SyncfusionExamples/WPF-39955_Sample
WPF-39955 Customize the axis grid lines in the WPF Chart
2 parents 412f66e + 3eccd55 commit 2e9e26a

15 files changed

+646
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="Customize_AxisGridLines_WPF_Chart.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:Customize_AxisGridLines_WPF_Chart"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace Customize_AxisGridLines_WPF_Chart
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{B2F7264B-F84E-480F-A68E-45B64D3F2C3C}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>Customize_AxisGridLines_WPF_Chart</RootNamespace>
10+
<AssemblyName>Customize_AxisGridLines_WPF_Chart</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<WarningLevel>4</WarningLevel>
15+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16+
<Deterministic>true</Deterministic>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<PlatformTarget>AnyCPU</PlatformTarget>
20+
<DebugSymbols>true</DebugSymbols>
21+
<DebugType>full</DebugType>
22+
<Optimize>false</Optimize>
23+
<OutputPath>bin\Debug\</OutputPath>
24+
<DefineConstants>DEBUG;TRACE</DefineConstants>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29+
<PlatformTarget>AnyCPU</PlatformTarget>
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="Syncfusion.Licensing" />
39+
<Reference Include="Syncfusion.SfChart.WPF" />
40+
<Reference Include="System" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Xml" />
43+
<Reference Include="Microsoft.CSharp" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="System.Xml.Linq" />
46+
<Reference Include="System.Data.DataSetExtensions" />
47+
<Reference Include="System.Net.Http" />
48+
<Reference Include="System.Xaml">
49+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
50+
</Reference>
51+
<Reference Include="WindowsBase" />
52+
<Reference Include="PresentationCore" />
53+
<Reference Include="PresentationFramework" />
54+
</ItemGroup>
55+
<ItemGroup>
56+
<ApplicationDefinition Include="App.xaml">
57+
<Generator>MSBuild:Compile</Generator>
58+
<SubType>Designer</SubType>
59+
</ApplicationDefinition>
60+
<Compile Include="ViewModel.cs" />
61+
<Page Include="MainWindow.xaml">
62+
<Generator>MSBuild:Compile</Generator>
63+
<SubType>Designer</SubType>
64+
</Page>
65+
<Compile Include="App.xaml.cs">
66+
<DependentUpon>App.xaml</DependentUpon>
67+
<SubType>Code</SubType>
68+
</Compile>
69+
<Compile Include="MainWindow.xaml.cs">
70+
<DependentUpon>MainWindow.xaml</DependentUpon>
71+
<SubType>Code</SubType>
72+
</Compile>
73+
</ItemGroup>
74+
<ItemGroup>
75+
<Compile Include="Properties\AssemblyInfo.cs">
76+
<SubType>Code</SubType>
77+
</Compile>
78+
<Compile Include="Properties\Resources.Designer.cs">
79+
<AutoGen>True</AutoGen>
80+
<DesignTime>True</DesignTime>
81+
<DependentUpon>Resources.resx</DependentUpon>
82+
</Compile>
83+
<Compile Include="Properties\Settings.Designer.cs">
84+
<AutoGen>True</AutoGen>
85+
<DependentUpon>Settings.settings</DependentUpon>
86+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
87+
</Compile>
88+
<EmbeddedResource Include="Properties\Resources.resx">
89+
<Generator>ResXFileCodeGenerator</Generator>
90+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
91+
</EmbeddedResource>
92+
<None Include="packages.config" />
93+
<None Include="Properties\Settings.settings">
94+
<Generator>SettingsSingleFileGenerator</Generator>
95+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
96+
</None>
97+
</ItemGroup>
98+
<ItemGroup>
99+
<None Include="App.config" />
100+
</ItemGroup>
101+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
102+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.4.33213.308
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Customize_AxisGridLines_WPF_Chart", "Customize_AxisGridLines_WPF_Chart.csproj", "{B2F7264B-F84E-480F-A68E-45B64D3F2C3C}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{B2F7264B-F84E-480F-A68E-45B64D3F2C3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B2F7264B-F84E-480F-A68E-45B64D3F2C3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B2F7264B-F84E-480F-A68E-45B64D3F2C3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{B2F7264B-F84E-480F-A68E-45B64D3F2C3C}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {E5547BB0-6397-47A9-BAD1-1E4E5581895B}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<Window x:Class="Customize_AxisGridLines_WPF_Chart.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:Customize_AxisGridLines_WPF_Chart"
7+
xmlns:chart="http://schemas.syncfusion.com/wpf"
8+
mc:Ignorable="d"
9+
Title="MainWindow" Height="450" Width="800">
10+
<Grid>
11+
<Grid.DataContext>
12+
<local:ViewModel />
13+
</Grid.DataContext>
14+
15+
<chart:SfChart Margin="20">
16+
17+
<chart:SfChart.Resources>
18+
<Style TargetType="Line" x:Key="gridLineStyle">
19+
<Setter Property="StrokeThickness" Value="2"/>
20+
<Setter Property="Stroke" Value="Gray"/>
21+
</Style>
22+
<Style TargetType="Line" x:Key="minorGridLineStyle">
23+
<Setter Property="StrokeThickness" Value="1"/>
24+
<Setter Property="Stroke" Value="LightGray"/>
25+
<Setter Property="StrokeDashArray" Value="3,3"/>
26+
</Style>
27+
<Style TargetType="Line" x:Key="tickLineStyle">
28+
<Setter Property="StrokeThickness" Value="2"/>
29+
<Setter Property="Stroke" Value="Gray"/>
30+
</Style>
31+
<Style TargetType="Line" x:Key="minorTickLineStyle">
32+
<Setter Property="StrokeThickness" Value="1"/>
33+
<Setter Property="Stroke" Value="LightGray"/>
34+
</Style>
35+
</chart:SfChart.Resources>
36+
37+
<chart:SfChart.PrimaryAxis>
38+
<chart:CategoryAxis Header="Months" ShowGridLines="False"
39+
PlotOffsetStart="10" PlotOffsetEnd="10"/>
40+
</chart:SfChart.PrimaryAxis>
41+
42+
<chart:SfChart.SecondaryAxis>
43+
<chart:NumericalAxis Header="Temperature (In Fahrenheit)" LabelFormat="0°F" SmallTicksPerInterval="2">
44+
<chart:NumericalAxis.MajorGridLineStyle>
45+
<Style TargetType="Line">
46+
<Setter Property="StrokeThickness" Value="2"/>
47+
<Setter Property="Stroke" Value="Green"/>
48+
</Style>
49+
</chart:NumericalAxis.MajorGridLineStyle>
50+
<chart:NumericalAxis.MinorGridLineStyle>
51+
<Style TargetType="Line">
52+
<Setter Property="StrokeThickness" Value="1"/>
53+
<Setter Property="Stroke" Value="Blue"/>
54+
<Setter Property="StrokeDashArray" Value="3,3"/>
55+
</Style>
56+
</chart:NumericalAxis.MinorGridLineStyle>
57+
<chart:NumericalAxis.MajorTickLineStyle>
58+
<Style TargetType="Line">
59+
<Setter Property="StrokeThickness" Value="2"/>
60+
<Setter Property="Stroke" Value="Green"/>
61+
</Style>
62+
</chart:NumericalAxis.MajorTickLineStyle>
63+
<chart:NumericalAxis.MinorTickLineStyle>
64+
<Style TargetType="Line">
65+
<Setter Property="StrokeThickness" Value="1"/>
66+
<Setter Property="Stroke" Value="Blue"/>
67+
<Setter Property="StrokeDashArray" Value="3,3"/>
68+
</Style>
69+
</chart:NumericalAxis.MinorTickLineStyle>
70+
</chart:NumericalAxis>
71+
</chart:SfChart.SecondaryAxis>
72+
73+
<chart:SplineSeries XBindingPath="XValue"
74+
YBindingPath="YValue1"
75+
ItemsSource="{Binding Data}" >
76+
<chart:SplineSeries.AdornmentsInfo>
77+
<chart:ChartAdornmentInfo Symbol="Ellipse">
78+
</chart:ChartAdornmentInfo>
79+
</chart:SplineSeries.AdornmentsInfo>
80+
</chart:SplineSeries>
81+
</chart:SfChart>
82+
</Grid>
83+
</Window>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace Customize_AxisGridLines_WPF_Chart
17+
{
18+
/// <summary>
19+
/// Interaction logic for MainWindow.xaml
20+
/// </summary>
21+
public partial class MainWindow : Window
22+
{
23+
public MainWindow()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System.Reflection;
2+
using System.Resources;
3+
using System.Runtime.CompilerServices;
4+
using System.Runtime.InteropServices;
5+
using System.Windows;
6+
7+
// General Information about an assembly is controlled through the following
8+
// set of attributes. Change these attribute values to modify the information
9+
// associated with an assembly.
10+
[assembly: AssemblyTitle("Customize_AxisGridLines_WPF_Chart")]
11+
[assembly: AssemblyDescription("")]
12+
[assembly: AssemblyConfiguration("")]
13+
[assembly: AssemblyCompany("")]
14+
[assembly: AssemblyProduct("Customize_AxisGridLines_WPF_Chart")]
15+
[assembly: AssemblyCopyright("Copyright © 2023")]
16+
[assembly: AssemblyTrademark("")]
17+
[assembly: AssemblyCulture("")]
18+
19+
// Setting ComVisible to false makes the types in this assembly not visible
20+
// to COM components. If you need to access a type in this assembly from
21+
// COM, set the ComVisible attribute to true on that type.
22+
[assembly: ComVisible(false)]
23+
24+
//In order to begin building localizable applications, set
25+
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
26+
//inside a <PropertyGroup>. For example, if you are using US english
27+
//in your source files, set the <UICulture> to en-US. Then uncomment
28+
//the NeutralResourceLanguage attribute below. Update the "en-US" in
29+
//the line below to match the UICulture setting in the project file.
30+
31+
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32+
33+
34+
[assembly: ThemeInfo(
35+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36+
//(used if a resource is not found in the page,
37+
// or application resource dictionaries)
38+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39+
//(used if a resource is not found in the page,
40+
// app, or any theme specific resource dictionaries)
41+
)]
42+
43+
44+
// Version information for an assembly consists of the following four values:
45+
//
46+
// Major Version
47+
// Minor Version
48+
// Build Number
49+
// Revision
50+
//
51+
// You can specify all the values or you can default the Build and Revision Numbers
52+
// by using the '*' as shown below:
53+
// [assembly: AssemblyVersion("1.0.*")]
54+
[assembly: AssemblyVersion("1.0.0.0")]
55+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)