Skip to content

Commit 2f3e699

Browse files
committed
943435-Moved Cards and Calendar UG to master
1 parent 0761f31 commit 2f3e699

File tree

4 files changed

+284
-0
lines changed

4 files changed

+284
-0
lines changed

maui-toolkit-toc.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<li><a href="/maui-toolkit/Calendar/getting-started">Getting Started</a></li>
5454
<li><a href="/maui-toolkit/Calendar/views">Views</a></li>
5555
<li><a href="/maui-toolkit/Calendar/selections">Selections</a></li>
56+
<li><a href="/maui-toolkit/Calendar/calendar-mode">Calendar Mode</a></li>
5657
<li><a href="/maui-toolkit/Calendar/calendar-identifier">Calendar Identifier</a></li>
5758
<li><a href="/maui-toolkit/Calendar/date-navigation">Date Navigation</a></li>
5859
<li><a href="/maui-toolkit/Calendar/date-restrictions">Date Restrictions</a></li>
@@ -64,6 +65,16 @@
6465
<li><a href="/maui-toolkit/Calendar/accessibility">Accessibility</a></li>
6566
</ul>
6667
</li>
68+
<li>
69+
SfCards
70+
<ul>
71+
<li><a href="/maui-toolkit/Cards/Overview">Overview</a></li>
72+
<li><a href="/maui-toolkit/Cards/Getting-Started">Getting Started</a></li>
73+
<li><a href="/maui-toolkit/Cards/Customization">Customization</a></li>
74+
<li><a href="/maui-toolkit/Cards/BindableLayout">BindableLayout</a></li>
75+
<li><a href="/maui-toolkit/Cards/Events">Events</a></li>
76+
</ul>
77+
</li>
6778
<li>
6879
SfCarousel
6980
<ul>
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
layout: post
3+
title: Calendar Modes in MAUI Calendar Control | Syncfusion<sup>&reg;</sup>
4+
description: Learn about the calendar modes in Syncfusion<sup>&reg;</sup> Calendar for .NET MAUI (SfCalendar) control and its basic features.
5+
platform: maui
6+
control: SfCalendar
7+
documentation: ug
8+
---
9+
10+
# Calendar mode in .NET MAUI Calendar (SfCalendar)
11+
12+
The Calendar mode is specified in the calendar property enumeration, which is used to display the calendar based on the modes. It offers three modes: [Default](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarMode.html#Syncfusion_Maui_Toolkit_Calendar_CalendarMode_Default), [Dialog](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarMode.html#Syncfusion_Maui_Toolkit_Calendar_CalendarMode_Dialog), and [RelativeDialog](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarMode.html#Syncfusion_Maui_Toolkit_Calendar_CalendarMode_RelativeDialog). The default calendar mode in the [SfCalendar](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html) is [Default](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarMode.html#Syncfusion_Maui_Toolkit_Calendar_CalendarMode_Default).
13+
14+
## Dialog Mode
15+
16+
The dialog mode is used to display the calendar in a pop-up by setting the [Mode](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html#Syncfusion_Maui_Toolkit_Calendar_SfCalendar_Mode) property to [Dialog](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarMode.html#Syncfusion_Maui_Toolkit_Calendar_CalendarMode_Dialog) in [SfCalendar](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html).
17+
18+
{% tabs %}
19+
20+
{% highlight xaml tabtitle="XAML" hl_lines="2" %}
21+
22+
<calendar:SfCalendar x:Name="calendar"
23+
Mode="Dialog"/>
24+
25+
{% endhighlight %}
26+
27+
{% highlight c# tabtitle="C#" hl_lines="3" %}
28+
29+
SfCalendar calendar = new SfCalendar()
30+
{
31+
Mode = CalendarMode.Dialog
32+
};
33+
34+
this.Content = calendar;
35+
36+
{% endhighlight %}
37+
38+
{% endtabs %}
39+
40+
The Calendar can be opened programmatically by setting the [IsOpen](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html#Syncfusion_Maui_Toolkit_Calendar_SfCalendar_IsOpen) property to `true` of [SfCalendar](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html). By default, the [IsOpen](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html#Syncfusion_Maui_Toolkit_Calendar_SfCalendar_IsOpen) property is `false`.
41+
42+
N> This property is automatically changed to `false` when you close the dialog by clicking outside of it.
43+
44+
{% tabs %}
45+
46+
{% highlight xaml tabtitle="MainPage.xaml" %}
47+
48+
<Grid>
49+
<calendar:SfCalendar x:Name="calendar"
50+
Mode="Dialog"/>
51+
<Button Text="Open Calendar"
52+
x:Name="calendarButton"
53+
Clicked="Button_Clicked"
54+
HorizontalOptions="Center"
55+
VerticalOptions="Center"
56+
HeightRequest="50"
57+
WidthRequest="150">
58+
</Button>
59+
</Grid>
60+
61+
{% endhighlight %}
62+
63+
{% highlight c# tabtitle="MainPage.xaml.cs" %}
64+
65+
private void Button_Clicked(object sender, System.EventArgs e)
66+
{
67+
this.calendar.IsOpen = true;
68+
}
69+
70+
{% endhighlight %}
71+
72+
{% endtabs %}
73+
74+
![Dialog mode in .NET MAUI Calendar.](images/calendar-mode/calendar_popup.gif)
75+
76+
77+
## Relative Dialog Mode
78+
79+
The relative dialog mode displays the calendar in a pop-up by setting the [Mode](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html#Syncfusion_Maui_Toolkit_Calendar_SfCalendar_Mode) property to [RelativeDialog](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarMode.html#Syncfusion_Maui_Toolkit_Calendar_CalendarMode_RelativeDialog). It is used to align the calendar in a specific position. You can set the position by using the [RelativePosition](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html#Syncfusion_Maui_Toolkit_Calendar_SfCalendar_RelativePosition) property in the [SfCalendar](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html).
80+
81+
### Relative position
82+
83+
The [RelativePosition](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html#Syncfusion_Maui_Toolkit_Calendar_SfCalendar_RelativePosition) is specified in the calendar property enumeration, which is used to align the calendar in a specific position. It provides eight positions such as [AlignTop](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarRelativePosition.html#Syncfusion_Maui_Toolkit_Calendar_CalendarRelativePosition_AlignTop), [AlignToLeftOf](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarRelativePosition.html#Syncfusion_Maui_Toolkit_Calendar_CalendarRelativePosition_AlignToLeftOf), [AlignToRightOf](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarRelativePosition.html#Syncfusion_Maui_Toolkit_Calendar_CalendarRelativePosition_AlignToRightOf), [AlignBottom](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarRelativePosition.html#Syncfusion_Maui_Toolkit_Calendar_CalendarRelativePosition_AlignBottom), [AlignTopLeft](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarRelativePosition.html#Syncfusion_Maui_Toolkit_Calendar_CalendarRelativePosition_AlignTopLeft), [AlignTopRight](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarRelativePosition.html#Syncfusion_Maui_Toolkit_Calendar_CalendarRelativePosition_AlignTopRight), [AlignBottomLeft](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarRelativePosition.html#Syncfusion_Maui_Toolkit_Calendar_CalendarRelativePosition_AlignBottomLeft), and [AlignBottomRight](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarRelativePosition.html#Syncfusion_Maui_Toolkit_Calendar_CalendarRelativePosition_AlignBottomRight). The default relative position in the [SfCalendar](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html) is [AlignTop](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.CalendarRelativePosition.html#Syncfusion_Maui_Toolkit_Calendar_CalendarRelativePosition_AlignTop).
84+
85+
The Calendar can be opened programmatically by setting the [IsOpen](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html#Syncfusion_Maui_Toolkit_Calendar_SfCalendar_IsOpen) property to `true` of [SfCalendar](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html). By default, the [IsOpen](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Calendar.SfCalendar.html#Syncfusion_Maui_Toolkit_Calendar_SfCalendar_IsOpen) property is `false`.
86+
87+
N> This property is automatically changed to `false` when you close the dialog by clicking outside of it.
88+
89+
{% tabs %}
90+
91+
{% highlight xaml tabtitle="MainPage.xaml" %}
92+
93+
<Grid>
94+
<calendar:SfCalendar x:Name="calendar"
95+
Mode="RelativeDialog"
96+
RelativePosition="AlignTopLeft">
97+
</calendar:SfCalendar>
98+
<Button Text="Open calendar"
99+
x:Name="calendarButton"
100+
Clicked="Button_Clicked"
101+
HorizontalOptions="Center"
102+
VerticalOptions="Center"
103+
HeightRequest="50"
104+
WidthRequest="150">
105+
</Button>
106+
</Grid>
107+
108+
{% endhighlight %}
109+
110+
{% highlight c# tabtitle="MainPage.xaml.cs" %}
111+
112+
private void Button_Clicked(object sender, System.EventArgs e)
113+
{
114+
this.calendar.IsOpen = true;
115+
}
116+
117+
{% endhighlight %}
118+
119+
{% endtabs %}
78.6 KB
Loading
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
layout: post
3+
title: BindableLayout in MAUI Cards control | Syncfusion<sup>&reg;</sup>
4+
description: Learn about BindableLayout support in Syncfusion<sup>&reg;</sup> Essential Studio<sup>&reg;</sup> MAUI Cards control, its elements and more.
5+
platform: MAUI
6+
control: Cards
7+
documentation: ug
8+
---
9+
10+
# BindableLayout in MAUI Cards
11+
12+
Layout&lt;T&gt; introduces a feature called `BindableLayout`, which works with all layouts derived from Layout&lt;T&gt;. By simply setting the ItemTemplate and ItemsSource, BindableLayout automatically generates a group of UI elements (based on the provided ItemTemplate) for each data item in the ItemsSource and adds them as children.
13+
14+
Since [`SfCardLayout`](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Cards.SfCardLayout.html) is an extended class of Layout&lt;T&gt;, this approach is also possible for `SfCardLayout`.
15+
16+
## Initialize view model
17+
18+
Define a simple data model that represents data to be populated for [`SfCardLayout`](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Cards.SfCardLayout.html).
19+
20+
{% highlight c# %}
21+
22+
public class Model
23+
{
24+
public IEnumerable<string> Colors { get; set; }
25+
}
26+
27+
{% endhighlight %}
28+
29+
Next, create a view model class and initialize a model object as demonstrated in the following code sample.
30+
31+
{% highlight c# %}
32+
33+
public class ViewModel
34+
{
35+
public Model Model { get; set; }
36+
37+
public ViewModel()
38+
{
39+
Model = new Model
40+
{
41+
Colors = new string[]
42+
{
43+
"Cyan", "Yellow", "Orange"
44+
}
45+
};
46+
}
47+
}
48+
49+
{% endhighlight %}
50+
51+
Set the ViewModel instance as BindingContext of your page to bind properties of ViewModel to [`SfCardLayout`](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Cards.SfCardLayout.html).
52+
53+
N> Add namespace of ViewModel class in your XAML page if you prefer to set BindingContext in XAML.
54+
55+
{% tabs %}
56+
57+
{% highlight xaml %}
58+
59+
<ContentPage.BindingContext>
60+
61+
<local:ViewModel/>
62+
63+
</ContentPage.BindingContext>
64+
65+
{% endhighlight %}
66+
67+
{% highlight c# %}
68+
69+
this.BindingContext = new ViewModel();
70+
71+
{% endhighlight %}
72+
73+
{% endtabs %}
74+
75+
## Populate CardLayout with data
76+
77+
[`SfCardLayout`](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Cards.SfCardLayout.html) can be populated with data by setting the ItemSource property of BindableLayout to a collection of items that can be used in [`SfCardView`](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Cards.SfCardView.html).
78+
79+
{% tabs %}
80+
81+
{% highlight xaml %}
82+
83+
<cards:SfCardLayout BindableLayout.ItemsSource="{Binding Model.Colors}">
84+
85+
</cards:SfCardLayout>
86+
87+
{% endhighlight %}
88+
89+
{% highlight c# %}
90+
91+
SfCardLayout cardLayout = new SfCardLayout();
92+
BindableLayout.SetItemsSource(cardLayout, viewModel.Model.Colors);
93+
94+
{% endhighlight %}
95+
96+
{% endtabs %}
97+
98+
## Define the appearance of SfCardView
99+
100+
[`SfCardLayout`](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Cards.SfCardLayout.html) accepts only [`SfCardView`](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Cards.SfCardView.html) as its child. The appearance of each [`SfCardView`](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Cards.SfCardView.html) can be defined by setting the `BindableLayout.ItemTemplate` property.
101+
102+
{% tabs %}
103+
104+
{% highlight xaml %}
105+
106+
<cards:SfCardLayout BindableLayout.ItemsSource="{Binding Model.Colors}" SwipeDirection="Left" VerticalOptions="Center" HeightRequest="300" WidthRequest="300" BackgroundColor="#F0F0F0">
107+
<BindableLayout.ItemTemplate>
108+
<DataTemplate>
109+
<cards:SfCardView BackgroundColor="{Binding}">
110+
<Label Text="{Binding}" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center"/>
111+
</cards:SfCardView>
112+
</DataTemplate>
113+
</BindableLayout.ItemTemplate>
114+
</cards:SfCardLayout>
115+
116+
{% endhighlight %}
117+
118+
{% highlight c# %}
119+
120+
SfCardLayout cardLayout = new SfCardLayout()
121+
{
122+
SwipeDirection = CardSwipeDirection.Left,
123+
BackgroundColor = Color.FromHex("#F0F0F0"),
124+
VerticalOptions = LayoutOptions.Center,
125+
HeightRequest = 300,
126+
WidthRequest = 300,
127+
};
128+
129+
this.BindingContext = viewModel;
130+
131+
DataTemplate dataTemplate = new DataTemplate(() =>
132+
{
133+
SfCardView cardView = new SfCardView();
134+
cardView.SetBinding(SfCardView.BackgroundColorProperty, new Binding() { Path = "."});
135+
136+
Label label = new Label()
137+
{
138+
HorizontalOptions = LayoutOptions.CenterAndExpand,
139+
VerticalTextAlignment = TextAlignment.Center
140+
};
141+
142+
label.SetBinding(Label.TextProperty, new Binding() { Path= "."});
143+
cardView.Content = label;
144+
return cardView;
145+
});
146+
147+
BindableLayout.SetItemTemplate(cardLayout, dataTemplate);
148+
BindableLayout.SetItemsSource(cardLayout, viewModel.Model.Colors);
149+
150+
this.Content = cardLayout;
151+
152+
{% endhighlight %}
153+
154+
{% endtabs %}

0 commit comments

Comments
 (0)