Skip to content

Commit 8a66f7d

Browse files
Merge pull request #1222 from telerik/master
merge master into dev
2 parents 4def070 + f78d997 commit 8a66f7d

17 files changed

+715
-22
lines changed

ai/mcp-server.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Option 1: License File Path (Recommended)
5050

5151
```json
5252
"env": {
53-
"TELERIK_LICENSE_PATH": "THE_PATH_TO_YOUR_LICENSE_FIL"
53+
"TELERIK_LICENSE_PATH": "THE_PATH_TO_YOUR_LICENSE_FILE"
5454
}
5555
```
5656

@@ -208,4 +208,4 @@ This setup allows you to use the Telerik AI Coding Assistant without cloud-based
208208
## See Also
209209

210210
* [Telerik MAUI GitHub Copilot Extension]({%slug ai-copilot-extension%})
211-
* [AI Coding Assistant Overview]({%slug ai-overview%})
211+
* [AI Coding Assistant Overview]({%slug ai-overview%})

controls/aiprompt/predefined-ai-commands.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ You can use three different approaches to add a logic that will be executed when
2626
Let's, for example, add the following `AIPromptCommand` to `Commands` collection:
2727

2828
```C#
29-
this.Commands.Add(new AIPromptCommand
30-
{ mageSource = new FontImageSource() { FontFamily = TelerikFont.Name, Size = 12, Glyph = TelerikFont.IconPaste},
31-
Text = "Simplify",
32-
Command = this.CheckSyntaxCommand });
29+
this.Commands.Add(new AIPromptCommand {
30+
mageSource = new FontImageSource() { FontFamily = TelerikFont.Name, Size = 12, Glyph = TelerikFont.IconPaste },
31+
Text = "Simplify",
32+
Command = this.CheckSyntaxCommand
33+
});
3334
this.CheckSyntaxCommand = new Command(this.ExecuteCheckSyntaxCommand);
3435
```
3536

@@ -49,9 +50,10 @@ In case the `AIPromptCommand` has `Command` applied, that `Command` will be exec
4950
In case the `AIPromptCommand`'`Command` is null, the AIPrompt's `CommandTappedCommand` will be executed:
5051

5152
```C#
52-
this.Commands.Add(new AIPromptCommand
53-
{ mageSource = new FontImageSource() { FontFamily = TelerikFont.Name, Size = 12, Glyph = TelerikFont.IconPaste},
54-
Text = "Simplify"});
53+
this.Commands.Add(new AIPromptCommand {
54+
mageSource = new FontImageSource() { FontFamily = TelerikFont.Name, Size = 12, Glyph = TelerikFont.IconPaste },
55+
Text = "Simplify"
56+
});
5557
this.CommandTappedCommand = new Command(this.ExecuteCommandTappedCommand);
5658
```
5759

controls/scheduler/styling/day-styling.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ slug: scheduler-day-styling
88

99
# .NET MAUI Scheduler Day Styling
1010

11-
The Scheduler control for .NET MAUI provides the `DayStyleSelector`(of type `Telerik.Maui.Controls.IStyleSelector`) property which specifies the style selector for the days displayed in the Scheduler. Its default implementation includes separate styles for Today date and all the other dates.
11+
The Scheduler control for .NET MAUI provides the `DayStyleSelector` (of type `Telerik.Maui.Controls.IStyleSelector`) property which specifies the style selector for the days displayed in the Scheduler. Its default implementation includes separate styles for Today date and all the other dates.
12+
13+
The Scheduler `MonthViewDefinition` allows you to style the appearance of the days names, by using the `DayNameStyleSelector` (of type `Telerik.Maui.Controls.IStyleSelector`) property.
1214

1315
The following example demonstrates how to style the days with a custom `DayStyleSelector` property which will add a different style for the days of the weekend:
1416

@@ -28,4 +30,4 @@ The following example demonstrates how to style the days with a custom `DayStyle
2830

2931
## See Also
3032

31-
-[Views]({% slug scheduler-views-overview %})
33+
- [Views]({% slug scheduler-views-overview %})

controls/scheduler/styling/scheduler-currenttime-indicator-styling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ The following example demonstrates how to apply a sample style to the current ti
2626

2727
## See Also
2828

29-
-[Current Time Indicator]({%slug scheduler-time-indicator%})
30-
-[Views]({% slug scheduler-views-overview %})
29+
- [Current Time Indicator]({%slug scheduler-time-indicator%})
30+
- [Views]({% slug scheduler-views-overview %})
3131

controls/scheduler/views/month-view.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Add a `MonthViewDefinition` to the `ViewDefinitions` collection of the `RadSched
2626

2727
## Properties
2828

29-
* `FirstDayOfWeek`—Defines the day that is considered the beginning of the week.
30-
* `HeaderTextFormat`—Defines the format string for the header text.
29+
* `FirstDayOfWeek` (enum of type `DayOfWeek?`)—Defines the day that is considered the beginning of the week.
30+
* `HeaderTextFormat` (`string`)—Defines the format string for the header text.
3131

3232
## See Also
3333

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
title: Accessing Controls Inside Dynamic Popup Loaded from DataTemplate in ResourceDictionary
3+
description: Learn how to dynamically load Popup content from a DataTemplate in a ResourceDictionary in UI for .NET MAUI and update the controls inside.
4+
type: how-to
5+
page_title: Updating Controls Inside Popup Loaded Dynamically from DataTemplate in ResourceDictionary
6+
meta_title: Updating Controls Inside Popup Loaded Dynamically from DataTemplate in ResourceDictionary
7+
slug: accessing-controls-inside-dynamic-radpopup-data-template
8+
tags: popup, datatemplate, radpopup, maui, binding
9+
res_type: kb
10+
---
11+
12+
## Environment
13+
14+
| Version | Product | Author |
15+
| --- | --- | ---- |
16+
| 11.0.1 | Popup for .NET MAUI | [Dobrinka Yordanova](https://www.telerik.com/blogs/author/dobrinka-yordanova) |
17+
18+
## Description
19+
20+
I want to load a `RadPopup` dynamically using a `DataTemplate` defined in a `ResourceDictionary` and access or update the controls (e.g., `Label`) inside the template. However, accessing controls using `x:Name` is not working. I need a solution to update the control's properties, such as the `Text` property of a `Label`, when the popup opens.
21+
22+
This knowledge base article also answers the following questions:
23+
- How to bind and update controls in a `RadPopup` `DataTemplate` in .NET MAUI?
24+
- How to dynamically modify the content of `RadPopup` in .NET MAUI?
25+
- How to set control properties inside `RadPopup` using bindings or code?
26+
27+
## Solution
28+
29+
To achieve this, you can use one of two approaches:
30+
* [Binding the controls to a `ViewModel`](#option-1-using-binding-with-viewmodel)
31+
* [Programmatically accessing the controls inside the `DataTemplate`.](#option-2-accessing-controls-programmatically)
32+
33+
### Option 1: Using Binding with ViewModel
34+
35+
Use bindings to update the control properties inside the `DataTemplate`. Bind the `Label`'s `Text` property to a `ViewModel` and ensure the binding mode is set to `TwoWay`.
36+
37+
**1.** Define a `ViewModel` with a property for binding:
38+
39+
```csharp
40+
public class ViewModel : NotifyPropertyChangedBase
41+
{
42+
private string myValue;
43+
44+
public ViewModel()
45+
{
46+
this.myValue = "hello";
47+
}
48+
49+
public string MyValue
50+
{
51+
get => this.myValue;
52+
set => this.UpdateValue(ref this.myValue, value);
53+
}
54+
}
55+
```
56+
57+
**2.** Set the `BindingContext` in your code-behind:
58+
59+
```csharp
60+
public partial class MainPage : ContentPage
61+
{
62+
ViewModel vm;
63+
64+
public MainPage()
65+
{
66+
InitializeComponent();
67+
this.vm = new ViewModel();
68+
this.BindingContext = this.vm;
69+
}
70+
71+
private void CheckBoxIsCheckedChanged(object sender, IsCheckedChangedEventArgs e)
72+
{
73+
if (e.NewValue == true)
74+
{
75+
this.popup.IsOpen = true;
76+
this.vm.MyValue = "value changed";
77+
}
78+
}
79+
}
80+
```
81+
82+
**3.** Define the `DataTemplate` in XAML and bind the `Label`'s `Text` property:
83+
84+
```xml
85+
<DataTemplate x:Key="PopupTemplate">
86+
<telerik:RadBorder CornerRadius="8"
87+
BackgroundColor="#F9F9F9"
88+
BorderColor="Red"
89+
BorderThickness="1"
90+
WidthRequest="300"
91+
Padding="12">
92+
<VerticalStackLayout Spacing="8">
93+
<Label Text="{Binding MyValue, Mode=TwoWay}" />
94+
</VerticalStackLayout>
95+
</telerik:RadBorder>
96+
</DataTemplate>
97+
```
98+
99+
### Option 2: Accessing Controls Programmatically
100+
101+
Directly access the controls inside the `DataTemplate` programmatically and update their properties.
102+
103+
**1.** Define the `DataTemplate` in XAML:
104+
105+
```xml
106+
<DataTemplate x:Key="PopupTemplate">
107+
<telerik:RadBorder CornerRadius="8"
108+
BackgroundColor="#F9F9F9"
109+
BorderColor="Red"
110+
BorderThickness="1"
111+
WidthRequest="300"
112+
Padding="12">
113+
<VerticalStackLayout Spacing="8">
114+
<Label />
115+
</VerticalStackLayout>
116+
</telerik:RadBorder>
117+
</DataTemplate>
118+
```
119+
120+
**2.** In the code-behind, dynamically load the content and update the control properties:
121+
122+
```csharp
123+
private void CheckBoxIsCheckedChanged(object sender, IsCheckedChangedEventArgs e)
124+
{
125+
if (e.NewValue == true)
126+
{
127+
this.popup.IsOpen = true;
128+
var dataTemplate = this.myPage.Resources["PopupTemplate"] as DataTemplate;
129+
130+
var popupcontent = dataTemplate.CreateContent() as View;
131+
this.popup.Content = popupcontent;
132+
133+
List<IVisualTreeElement> items = (List<IVisualTreeElement>)this.popup.Content.GetVisualTreeDescendants();
134+
foreach (IVisualTreeElement myControl in items)
135+
{
136+
if (myControl is Label)
137+
{
138+
Label control = (Label)myControl;
139+
control.Text = "popup content has been changed when opened";
140+
return;
141+
}
142+
}
143+
}
144+
}
145+
```
146+
147+
### Key Considerations:
148+
149+
- Accessing controls inside a `DataTemplate` using `x:Name` is not possible due to the general behavior of the MAUI framework.
150+
- Use bindings if you want to follow MVVM principles.
151+
- For direct control access, ensure the `DataTemplate` content is created and assigned to the popup before attempting to modify controls.
152+
153+
## See Also
154+
155+
- [.NET MAUI Popup Documentation](https://docs.telerik.com/devtools/maui/controls/popup/overview)
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: Creating a Bar Indicator with Color Based on Axis Size in UI for .NET MAUI
3+
description: Learn how to create a bar indicator in UI for .NET MAUI and change its color based on axis size.
4+
type: how-to
5+
page_title: Changing Bar Indicator Color Based on Axis Size in UI for .NET MAUI
6+
meta_title: Changing Bar Indicator Color Based on Axis Size in UI for .NET MAUI
7+
slug: changing-bar-indicator-color-based-on-axis-size-dotnet-maui
8+
tags: progressbar, ui-for-dotnet-maui, axis-size, progress-fill
9+
res_type: kb
10+
---
11+
12+
## Environment
13+
14+
| Version | Product | Author |
15+
| --- | --- | ---- |
16+
| 11.0.1 | ProgressBar for .NET MAUI | [Dobrinka Yordanova](https://www.telerik.com/blogs/author/dobrinka-yordanova) |
17+
18+
## Description
19+
20+
I want to create a bar indicator and dynamically change its color based on the axis size rather than the indicator size.
21+
22+
This knowledge base article also answers the following questions:
23+
- How to make a bar indicator color change dynamically in UI for .NET MAUI?
24+
- How to bind bar indicator color to axis size in UI for .NET MAUI?
25+
- How to use LinearProgressBar as an alternative to Gauge in UI for .NET MAUI?
26+
27+
## Solution
28+
29+
To achieve the scenario, use the [LinearProgressBar](https://docs.telerik.com/devtools/maui/controls/progressbar/overview).
30+
31+
32+
**1.** Bind the slider value to the progress bar and define a color gradient for the progress fill.
33+
34+
```xaml
35+
<VerticalStackLayout Padding="10" x:Name="vsl1">
36+
<Label Text="{Binding Value, Source={x:Reference slider}}" />
37+
<Slider Value="{Binding Data, Mode=TwoWay}" x:Name="slider" Minimum="0" Maximum="10" />
38+
39+
<VerticalStackLayout x:Name="vsl2" SizeChanged="vsl2_SizeChanged">
40+
<telerik:RadLinearProgressBar x:Name="prgsBar"
41+
Minimum="0"
42+
Maximum="10"
43+
TrackFill="Transparent"
44+
Value="{Binding Source={x:Reference slider}, Path=Value}"
45+
HeightRequest="50">
46+
<telerik:RadLinearProgressBar.ProgressFill>
47+
<LinearGradientBrush>
48+
<LinearGradientBrush.GradientStops>
49+
<GradientStop Offset="0.0" Color="Yellow" />
50+
<GradientStop Offset="0.5" Color="Red" />
51+
<GradientStop Offset="1.0" Color="Green" />
52+
</LinearGradientBrush.GradientStops>
53+
</LinearGradientBrush>
54+
</telerik:RadLinearProgressBar.ProgressFill>
55+
</telerik:RadLinearProgressBar>
56+
</VerticalStackLayout>
57+
</VerticalStackLayout>
58+
```
59+
60+
**2.** Use the `SizeChanged` event to dynamically clip the axis size.
61+
62+
```csharp
63+
public partial class MainPage : ContentPage
64+
{
65+
public MainPage()
66+
{
67+
InitializeComponent();
68+
this.BindingContext = new ViewModel();
69+
}
70+
71+
private void vsl2_SizeChanged(object sender, EventArgs e)
72+
{
73+
this.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(100), () =>
74+
{
75+
double fromThickness = 10;
76+
PathFigure pf = new PathFigure
77+
{
78+
StartPoint = new Point(0, this.vsl2.Height)
79+
};
80+
pf.Segments.Add(new LineSegment(new Point(this.vsl2.Width, this.vsl2.Height)));
81+
pf.Segments.Add(new LineSegment(new Point(this.vsl2.Width, 0)));
82+
pf.Segments.Add(new LineSegment(new Point(0, this.vsl2.Height - fromThickness)));
83+
PathGeometry pg = new PathGeometry();
84+
pg.Figures.Add(pf);
85+
this.vsl2.Clip = pg;
86+
});
87+
}
88+
}
89+
90+
public class ViewModel : NotifyPropertyChangedBase
91+
{
92+
private double data = 10;
93+
public double Data
94+
{
95+
get => this.data;
96+
set => this.UpdateValue(ref this.data, value);
97+
}
98+
}
99+
```
100+
101+
By using `RadLinearProgressBar`, the color gradient is defined independently of the indicator size and adapts based on axis dimensions.
102+
103+
## See Also
104+
105+
- [LinearProgressBar Overview](https://docs.telerik.com/devtools/maui/controls/progressbar/overview)
106+
- [PathGeometry Class Documentation](https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/shapes/geometries?view=net-maui-9.0)
107+
- [SizeChanged Event in .NET MAUI](https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.controls.visualelement.sizechanged?view=net-maui-9.0)

knowledge-base/chart-line-series-datapoint-markers.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ public partial class MainPage : ContentPage
136136
platformSeries.Style.PointShape = new TelerikUI.TKPredefinedShape(TelerikUI.TKShapeType.Circle, new System.Drawing.SizeF(10, 10));
137137
platformSeries.Style.ShapeMode = TelerikUI.TKChartSeriesStyleShapeMode.AlwaysShow;
138138

139+
#elif WINDOWS
140+
141+
var platformChart = (Telerik.UI.Xaml.Controls.Chart.RadCartesianChart)platformView;
142+
var platformSeries = (Telerik.UI.Xaml.Controls.Chart.LineSeries)platformChart.Series[0];
143+
var nativeApp = MauiWinUIApplication.Current;
144+
platformSeries.PointTemplate = nativeApp.Resources["PointTemplate"] as Microsoft.UI.Xaml.DataTemplate;
139145
#endif
140146
}
141147
}
@@ -163,6 +169,18 @@ public class PointRenderer : Java.Lang.Object, global::Com.Telerik.Widget.Chart.
163169
}
164170
```
165171

166-
And this is the result:
172+
**6.** For WinUI, add the `PointTemplate` inside the `Platforms/Windows/App.xaml` file:
173+
174+
```XAML
175+
<maui:MauiWinUIApplication.Resources>
176+
<ResourceDictionary>
177+
<DataTemplate x:Key="PointTemplate">
178+
<Ellipse Width="20" Height="20" Fill="Blue" Stroke="Black" StrokeThickness="1"/>
179+
</DataTemplate>
180+
</ResourceDictionary>
181+
</maui:MauiWinUIApplication.Resources>
182+
```
183+
184+
And the result on Android:
167185

168-
[.NET MAUI Chart Point Markers](images/chart-pointmarkers-result.png)
186+
![.NET MAUI Chart Point Markers](images/chart-pointmarkers-result.png)

0 commit comments

Comments
 (0)