Skip to content

Commit 71b384a

Browse files
Merge pull request #2 from SyncfusionExamples/ZoomInandZoomOutWPFChart
How to zoom in and out of a WPF Chart in the scroll viewer
2 parents b45690b + c9560a1 commit 71b384a

File tree

73 files changed

+48
-211024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+48
-211024
lines changed

Zoom_WPF_Chart_Inside_ScrollViewer/App.xaml renamed to Zoom_WPF_Chart/App.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Application x:Class="Zoom_WPF_Chart_Inside_ScrollViewer.App"
1+
<Application x:Class="Zoom_WPF_Chart.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:local="clr-namespace:Zoom_WPF_Chart_Inside_ScrollViewer"
4+
xmlns:local="clr-namespace:Zoom_WPF_Chart"
55
StartupUri="MainWindow.xaml">
66
<Application.Resources>
77

Zoom_WPF_Chart_Inside_ScrollViewer/App.xaml.cs renamed to Zoom_WPF_Chart/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Threading.Tasks;
77
using System.Windows;
88

9-
namespace Zoom_WPF_Chart_Inside_ScrollViewer
9+
namespace Zoom_WPF_Chart
1010
{
1111
/// <summary>
1212
/// Interaction logic for App.xaml

Zoom_WPF_Chart/AssemblyInfo.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]

Zoom_WPF_Chart_Inside_ScrollViewer/MainWindow.xaml renamed to Zoom_WPF_Chart/MainWindow.xaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
<Window x:Class="Zoom_WPF_Chart_Inside_ScrollViewer.MainWindow"
1+
<Window x:Class="Zoom_WPF_Chart.MainWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6-
xmlns:local="clr-namespace:Zoom_WPF_Chart_Inside_ScrollViewer"
6+
xmlns:local="clr-namespace:Zoom_WPF_Chart"
77
mc:Ignorable="d"
88
Title="MainWindow" Height="450" Width="800"
9-
xmlns:chart="clr-namespace:Syncfusion.UI.Xaml.Charts;assembly=Syncfusion.SfChart.WPF">
10-
9+
xmlns:chart="clr-namespace:Syncfusion.UI.Xaml.Charts;assembly=Syncfusion.SfChart.WPF">
10+
1111
<Window.DataContext>
1212
<local:ViewModel/>
1313
</Window.DataContext>
@@ -75,5 +75,4 @@
7575
</chart:SfChart>
7676
</StackPanel>
7777
</local:ScrollViewerExt>
78-
7978
</Window>

Zoom_WPF_Chart_Inside_ScrollViewer/MainWindow.xaml.cs renamed to Zoom_WPF_Chart/MainWindow.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
using System.Windows.Navigation;
1515
using System.Windows.Shapes;
1616

17-
namespace Zoom_WPF_Chart_Inside_ScrollViewer
17+
namespace Zoom_WPF_Chart
1818
{
1919
/// <summary>
2020
/// Interaction logic for MainWindow.xaml
@@ -27,14 +27,14 @@ public MainWindow()
2727
}
2828
}
2929

30-
public class ScrollViewerExt: ScrollViewer
30+
public class ScrollViewerExt : ScrollViewer
3131
{
3232
protected override void OnMouseWheel(MouseWheelEventArgs e)
3333
{
3434
// To restrict scroll action on chart
3535
if (e.Source is SfChart)
3636
return;
37-
37+
3838
base.OnMouseWheel(e);
3939
}
4040
}

Zoom_WPF_Chart_Inside_ScrollViewer/ViewModel.cs renamed to Zoom_WPF_Chart/ViewModel.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66

7-
namespace Zoom_WPF_Chart_Inside_ScrollViewer
7+
namespace Zoom_WPF_Chart
88
{
99
public class ViewModel
1010
{
@@ -13,28 +13,28 @@ public class ViewModel
1313
public List<Person> Revenue { get; set; }
1414
public List<Person> Profit { get; set; }
1515
public List<Person> Data { get; set; }
16-
16+
1717
public ViewModel()
1818
{
1919
ProductA = new List<Person>();
2020
ProductB = new List<Person>();
21-
21+
2222
Revenue = new List<Person>();
2323
Profit = new List<Person>();
24-
24+
2525
Data = new List<Person>();
26-
26+
2727
DateTime dateTime = new DateTime(2018, 1, 1);
2828
DateTime months = new DateTime(2018, 1, 1);
2929
Random random = new Random();
30-
30+
3131
for (int i = 1; i <= 25; i++)
3232
{
3333
ProductA.Add(new Person { Date = dateTime, Sales = random.Next(0, 2000) });
3434
ProductB.Add(new Person { Date = dateTime, Sales = random.Next(0, 2000) });
3535
dateTime = dateTime.AddDays(15);
3636
}
37-
37+
3838
for (int i = 1; i <= 12; i++)
3939
{
4040
Revenue.Add(new Person { Date = months, Revenue = random.Next(1800, 2300) });
@@ -56,7 +56,7 @@ public ViewModel()
5656
public class Person
5757
{
5858
public string Name { get; set; }
59-
59+
6060
public DateTime Date { get; set; }
6161

6262
public double Sales { get; set; }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net7.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<UseWPF>true</UseWPF>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.SfChart.WPF" Version="21.1.37" />
12+
</ItemGroup>
13+
14+
</Project>

Zoom_WPF_Chart_Inside_ScrollViewer/Zoom_WPF_Chart_Inside_ScrollViewer.sln renamed to Zoom_WPF_Chart/Zoom_WPF_Chart.sln

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.5.33103.201
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zoom_WPF_Chart_Inside_ScrollViewer", "Zoom_WPF_Chart_Inside_ScrollViewer.csproj", "{6DCFD017-E381-4551-864B-3379F31FF828}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zoom_WPF_Chart", "Zoom_WPF_Chart.csproj", "{77C1F2DC-E433-4020-8493-59B246E93BD0}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{6DCFD017-E381-4551-864B-3379F31FF828}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{6DCFD017-E381-4551-864B-3379F31FF828}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{6DCFD017-E381-4551-864B-3379F31FF828}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{6DCFD017-E381-4551-864B-3379F31FF828}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{77C1F2DC-E433-4020-8493-59B246E93BD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{77C1F2DC-E433-4020-8493-59B246E93BD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{77C1F2DC-E433-4020-8493-59B246E93BD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{77C1F2DC-E433-4020-8493-59B246E93BD0}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {372FA6E2-986D-4CE2-8327-B998B61878C9}
23+
SolutionGuid = {7DABFA75-FF09-4F75-9929-475DB2B55E9B}
2424
EndGlobalSection
2525
EndGlobal

Zoom_WPF_Chart_Inside_ScrollViewer/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

Zoom_WPF_Chart_Inside_ScrollViewer/Properties/Resources.Designer.cs

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)