Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Maui.Controls.Shapes;
using Syncfusion.Maui.Toolkit.Calendar;
using System.ComponentModel;
using System.Globalization;
using System.Xml;
Expand Down Expand Up @@ -50,7 +51,10 @@ public AppearanceViewModel()
border.Stroke = _isLightTheme ? Color.FromRgba("#6750A4") : Color.FromRgba("#D0BCFF");

Label label = new Label();
label.SetBinding(Label.TextProperty, "Date.Day");
label.SetBinding(Label.TextProperty, BindingHelper.CreateBinding(
propertyName: "Date.Day",
getter: static (CalendarCellDetails context) => context.Date.Day));

label.HorizontalOptions = LayoutOptions.Center;
label.VerticalOptions = LayoutOptions.Center;
label.Padding = new Thickness(2);
Expand All @@ -77,7 +81,10 @@ public AppearanceViewModel()
border.Stroke = _isLightTheme ? Color.FromRgba("#6750A4") : Color.FromRgba("#D0BCFF");

Label label = new Label();
label.SetBinding(Label.TextProperty, "Date.Day");
label.SetBinding(Label.TextProperty, BindingHelper.CreateBinding(
propertyName: "Date.Day",
getter: static (CalendarCellDetails context) => context.Date.Day));

label.HorizontalOptions = LayoutOptions.Center;
label.VerticalOptions = LayoutOptions.Center;
border.Content = label;
Expand Down
44 changes: 44 additions & 0 deletions maui/src/BindingHelper/BindingHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Microsoft.Maui.Controls.Internals;

/// <summary>
/// Helper class for creating bindings in .NET MAUI applications.
/// </summary>
public static class BindingHelper
{
/// <summary>
/// Creates a typed binding for a given source and its properties.
/// </summary>
/// <typeparam name="TSource">The type of the binding source.</typeparam>
/// <typeparam name="TProperty">The type of the property to bind.</typeparam>
/// <param name="propertyName">The name of the property to bind to.</param>
/// <param name="getter">A function to get the value of the property from the source.</param>
/// <param name="setter">An optional action to set the value of the property on the source.</param>
/// <param name="mode">The binding mode that determines the data flow direction.</param>
/// <param name="converter">An optional value converter for the binding.</param>
/// <param name="converterParameter">An optional parameter used by the converter.</param>
/// <param name="source">The source object for binding.</param>
/// <returns>A <see cref="BindingBase"/> representing the created binding.</returns>
public static BindingBase CreateBinding<TSource, TProperty>(
string propertyName,
Func<TSource, TProperty> getter,
Action<TSource, TProperty>? setter = null,
BindingMode mode = BindingMode.Default,
IValueConverter? converter = null,
object? converterParameter = null,
object? source = null)
{
return new TypedBinding<TSource, TProperty>(
getter: source => (getter(source), true),
setter,
handlers:
[
new(static source => source, propertyName),
])
{
Converter = converter,
ConverterParameter = converterParameter,
Mode = mode,
Source = source,
};
}
}
50 changes: 35 additions & 15 deletions maui/src/Calendar/Helper/CalendarViewHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1619,23 +1619,43 @@ internal static string GetLanguage(string calendarIdentifier)
/// <returns>A calendar instance.</returns>
internal static Globalization.Calendar GetCalendar(string calendarIdentifier)
{
var type = Type.GetType("System.Globalization." + calendarIdentifier + "Calendar");
if (type != null)
switch (calendarIdentifier)
{
var calendar = Activator.CreateInstance(type) as Globalization.Calendar;
if (calendar != null)
{
return calendar;
}
else
{

case "Gregorian":

return new GregorianCalendar();

case "Hijri":

return new HijriCalendar();

case "Persian":

return new PersianCalendar();

case "ThaiBuddhist":

return new ThaiBuddhistCalendar();

case "Taiwan":

return new TaiwanCalendar();

case "UmAlQura":

return new UmAlQuraCalendar();

case "Korean":

return new KoreanCalendar();

default:

// If calendar identifier is specified wrongly, then default calendar will be used.

return CultureInfo.CurrentUICulture.DateTimeFormat.Calendar;
}
}
else
{
// If calendar identifier is specified wrongly, then default calendar will be used.
return CultureInfo.CurrentUICulture.DateTimeFormat.Calendar;

}
}

Expand Down
155 changes: 155 additions & 0 deletions maui/src/Calendar/Resources/SfCalendar.en-US.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

Version 2.0

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="OK" xml:space="preserve">
<value>OK</value>
<comment>Text for disabled item</comment>
</data>
<data name="Cancel" xml:space="preserve">
<value>Cancel</value>
<comment>Text for selected item</comment>
</data>
<data name="Today" xml:space="preserve">
<value>Today</value>
</data>
<data name="Special Date" xml:space="preserve">
<value>Special Date</value>
</data>
<data name="Blackout Date" xml:space="preserve">
<value>Blackout Date</value>
</data>
<data name="Disabled Date" xml:space="preserve">
<value>Disabled Date</value>
</data>
<data name="Week" xml:space="preserve">
<value>Week</value>
</data>
<data name="Disabled Cell" xml:space="preserve">
<value>Disabled Cell</value>
</data>
<data name="To" xml:space="preserve">
<value>To</value>
</data>
<data name="Forward" xml:space="preserve">
<value>Forward</value>
</data>
<data name="Backward" xml:space="preserve">
<value>Backward</value>
</data>
</root>
1 change: 1 addition & 0 deletions maui/src/Calendar/SfCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public partial class SfCalendar : SfView, ICalendar, IHeader, IFooterView, IPare
/// </summary>
public SfCalendar()
{
SfCalendarResources.InitializeDefaultResource("Syncfusion.Maui.Toolkit.Calendar.Resources.SfCalendar", typeof(SfCalendar));
ThemeElement.InitializeThemeResources(this, "SfCalendarTheme");
_proxy = new(this);
DrawingOrder = DrawingOrder.AboveContent;
Expand Down
2 changes: 2 additions & 0 deletions maui/src/Charts/Axis/CategoryAxis.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections;
using System.Diagnostics.CodeAnalysis;

namespace Syncfusion.Maui.Toolkit.Charts
{
Expand Down Expand Up @@ -84,6 +85,7 @@ internal void GroupData()
}
}

[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
internal override void GenerateVisibleLabels()
{
if (VisibleRange.IsEmpty)
Expand Down
2 changes: 2 additions & 0 deletions maui/src/Charts/Axis/DateTimeAxis.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Maui.Graphics;

namespace Syncfusion.Maui.Toolkit.Charts
Expand Down Expand Up @@ -182,6 +183,7 @@ internal void OnMinMaxChanged()
}
}

[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
internal override void GenerateVisibleLabels()
{
SmallTickPoints.Clear();
Expand Down
5 changes: 4 additions & 1 deletion maui/src/Charts/Axis/LogarithmicAxis.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Syncfusion.Maui.Toolkit.Charts
using System.Diagnostics.CodeAnalysis;

namespace Syncfusion.Maui.Toolkit.Charts
{
public partial class LogarithmicAxis : RangeAxisBase
{
Expand Down Expand Up @@ -125,6 +127,7 @@ internal override DoubleRange AddDefaultRange(double start)
return new DoubleRange(start, start + 1);
}

[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
internal override void GenerateVisibleLabels()
{
if (VisibleRange.IsEmpty)
Expand Down
5 changes: 4 additions & 1 deletion maui/src/Charts/Axis/NumericalAxis.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Syncfusion.Maui.Toolkit.Charts
using System.Diagnostics.CodeAnalysis;

namespace Syncfusion.Maui.Toolkit.Charts
{
public partial class NumericalAxis : RangeAxisBase
{
Expand Down Expand Up @@ -110,6 +112,7 @@ internal override void RaiseCallBackActualRangeChanged()
#endregion

#region Internal Methods
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
internal override void GenerateVisibleLabels()
{
var actualLabels = VisibleLabels;
Expand Down
3 changes: 2 additions & 1 deletion maui/src/Charts/Behaviors/ChartTooltipBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ void GenerateTooltip(IChart chart, float x, float y, bool canAnimate)
tooltip.BindingContext = tooltipInfo;
tooltip.Duration = Duration;
tooltip.Position = tooltipInfo.Position;
tooltip.SetBinding(SfTooltip.BackgroundProperty, nameof(TooltipInfo.Background));
tooltip.SetBinding(SfTooltip.BackgroundProperty,
BindingHelper.CreateBinding(nameof(TooltipInfo.Background), getter: static(TooltipInfo tooltipInfo1) => tooltipInfo1.Background));
tooltip.Content = GetTooltipTemplate(tooltipInfo);
tooltip.Show(seriesBounds, tooltipInfo.TargetRect, canAnimate);
}
Expand Down
Loading