Skip to content

Commit 2f0d448

Browse files
Adding MAUI DateTime Range Selector sample
Adding MAUI DateTime Range Selector sample
1 parent 862e9da commit 2f0d448

39 files changed

+1152
-2
lines changed

MauiProject.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31611.283
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiProject", "MauiProject\MauiProject.csproj", "{C913BA91-18B5-4F39-B813-E6B3E6700DD6}"
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+
{C913BA91-18B5-4F39-B813-E6B3E6700DD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C913BA91-18B5-4F39-B813-E6B3E6700DD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C913BA91-18B5-4F39-B813-E6B3E6700DD6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{C913BA91-18B5-4F39-B813-E6B3E6700DD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{C913BA91-18B5-4F39-B813-E6B3E6700DD6}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{C913BA91-18B5-4F39-B813-E6B3E6700DD6}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
26+
EndGlobalSection
27+
EndGlobal

MauiProject/App.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:MauiProject"
5+
x:Class="MauiProject.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>

MauiProject/App.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace MauiProject;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Mgo+DSMBMAY9C3t2VVhiQlFaclxJVHxOYVF2R2FJeVRzdV9HaUwgOX1dQl9hSXZTfkVrW3tacHdWRWk=");
9+
MainPage = new AppShell();
10+
}
11+
}

MauiProject/AppShell.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="MauiProject.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:MauiProject"
7+
Shell.FlyoutBehavior="Disabled">
8+
9+
<ShellContent
10+
Title="Home"
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>

MauiProject/AppShell.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace MauiProject;
2+
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}

MauiProject/ChartModel.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace MauiProject
8+
{
9+
public class ChartModel
10+
{
11+
public DateTime X { get; set; }
12+
public double Y { get; set; }
13+
}
14+
}

MauiProject/DataViewModel.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace MauiProject
8+
{
9+
public class DataViewModel
10+
{
11+
public List<ChartModel> Data { get; set; }
12+
public DataViewModel() {
13+
Data = new List<ChartModel>()
14+
{
15+
new ChartModel{ X = new DateTime(2022, 01, 01), Y = 350 },
16+
new ChartModel{ X = new DateTime(2022, 02, 01), Y = 375 },
17+
new ChartModel{ X = new DateTime(2022, 03, 01), Y = 500 },
18+
new ChartModel{ X = new DateTime(2022, 04, 01), Y = 390 },
19+
new ChartModel{ X = new DateTime(2022, 05, 01), Y = 400 },
20+
new ChartModel{ X = new DateTime(2022, 06, 01), Y = 440 },
21+
new ChartModel{ X = new DateTime(2022, 07, 01), Y = 350 },
22+
new ChartModel{ X = new DateTime(2022, 08, 01), Y = 400 },
23+
new ChartModel{ X = new DateTime(2022, 09, 01), Y = 365 },
24+
new ChartModel{ X = new DateTime(2022, 10, 01), Y = 490 },
25+
new ChartModel{ X = new DateTime(2022, 11, 01), Y = 400 },
26+
new ChartModel{ X = new DateTime(2022, 12, 01), Y = 520 },
27+
new ChartModel{ X = new DateTime(2023, 01, 01), Y = 375 },
28+
new ChartModel{ X = new DateTime(2023, 02, 01), Y = 350 },
29+
new ChartModel{ X = new DateTime(2023, 03, 01), Y = 398 },
30+
};
31+
}
32+
}
33+
}

MauiProject/MainPage.xaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:sf="clr-namespace:Syncfusion.Maui.Sliders;assembly=Syncfusion.Maui.Sliders"
5+
xmlns:charts="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts"
6+
xmlns:local="clr-namespace:MauiProject"
7+
x:Class="MauiProject.MainPage">
8+
9+
<sf:SfDateTimeRangeSelector ShowLabels="True"
10+
ShowTicks="True"
11+
ShowDividers="True"
12+
MinorTicksPerInterval="1"
13+
StepDuration="0,2"
14+
IsInversed="True"
15+
HeightRequest="210"
16+
Minimum="2022-01-01"
17+
Maximum="2023-03-01"
18+
RangeStart="2022-03-01"
19+
RangeEnd="2023-01-01"
20+
IntervalType="Months"
21+
Interval="2"
22+
DateFormat="MMM yy">
23+
<sf:SfDateTimeRangeSelector.DividerStyle>
24+
<sf:SliderDividerStyle ActiveRadius="4" InactiveRadius="6"/>
25+
</sf:SfDateTimeRangeSelector.DividerStyle>
26+
<sf:SfDateTimeRangeSelector.Tooltip>
27+
<sf:SliderTooltip />
28+
</sf:SfDateTimeRangeSelector.Tooltip>
29+
<charts:SfCartesianChart>
30+
31+
<charts:SfCartesianChart.BindingContext>
32+
<local:DataViewModel/>
33+
</charts:SfCartesianChart.BindingContext>
34+
35+
<charts:SfCartesianChart.XAxes>
36+
<charts:DateTimeAxis IsVisible="False"
37+
ShowMajorGridLines="False" />
38+
</charts:SfCartesianChart.XAxes>
39+
40+
<charts:SfCartesianChart.YAxes>
41+
<charts:NumericalAxis IsVisible="False"
42+
ShowMajorGridLines="False" />
43+
</charts:SfCartesianChart.YAxes>
44+
45+
<charts:SfCartesianChart.Series>
46+
<charts:SplineAreaSeries ItemsSource="{Binding Data}"
47+
XBindingPath="X"
48+
YBindingPath="Y">
49+
</charts:SplineAreaSeries>
50+
</charts:SfCartesianChart.Series>
51+
52+
</charts:SfCartesianChart>
53+
</sf:SfDateTimeRangeSelector>
54+
55+
</ContentPage>

MauiProject/MainPage.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace MauiProject;
2+
3+
public partial class MainPage : ContentPage
4+
{
5+
public MainPage()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+

MauiProject/MauiProgram.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.Extensions.Logging;
2+
using Syncfusion.Maui.Core.Hosting;
3+
namespace MauiProject;
4+
5+
public static class MauiProgram
6+
{
7+
public static MauiApp CreateMauiApp()
8+
{
9+
var builder = MauiApp.CreateBuilder();
10+
builder
11+
.UseMauiApp<App>()
12+
.ConfigureSyncfusionCore()
13+
.ConfigureFonts(fonts =>
14+
{
15+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
16+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
17+
});
18+
19+
#if DEBUG
20+
builder.Logging.AddDebug();
21+
#endif
22+
23+
return builder.Build();
24+
}
25+
}

0 commit comments

Comments
 (0)