AOT safe panels.

This commit is contained in:
Burak Kaan Köse
2026-01-06 11:45:03 +01:00
parent f8333aab10
commit be6b23c47b
2 changed files with 47 additions and 16 deletions
@@ -27,7 +27,7 @@
<!-- Vertical panel that renders items on canvas. --> <!-- Vertical panel that renders items on canvas. -->
<DataTemplate x:Key="DayCalendarItemVerticalRenderTemplate" x:DataType="models:CalendarDayModel"> <DataTemplate x:Key="DayCalendarItemVerticalRenderTemplate" x:DataType="models:CalendarDayModel">
<ItemsControl x:Name="RegularEventItemsControl" ItemsSource="{x:Bind EventsCollection.RegularEvents}"> <ItemsControl x:Name="RegularEventItemsControl" ItemsSource="{x:Bind EventsCollection.RegularEvents}" Loaded="OnRegularEventItemsControlLoaded">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<!-- Default Calendar Item View Model Template --> <!-- Default Calendar Item View Model Template -->
<DataTemplate x:DataType="data:CalendarItemViewModel"> <DataTemplate x:DataType="data:CalendarItemViewModel">
@@ -41,8 +41,7 @@
</ItemsControl.ItemContainerTransitions> </ItemsControl.ItemContainerTransitions>
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<!-- TODO: Make aot safe. --> <controls:WinoCalendarPanel />
<controls:WinoCalendarPanel HourHeight="{Binding CalendarRenderOptions.CalendarSettings.HourHeight}" Period="{Binding Period}" />
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
</ItemsControl> </ItemsControl>
@@ -61,7 +60,7 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ItemsControl Margin="50,0,16,0" ItemsSource="{x:Bind CalendarDays}"> <ItemsControl x:Name="DayColumnsItemsControl" Margin="50,0,16,0" ItemsSource="{x:Bind CalendarDays}" Loaded="OnDayColumnsItemsControlLoaded">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate x:DataType="models:CalendarDayModel"> <DataTemplate x:DataType="models:CalendarDayModel">
<controls:DayColumnControl DayModel="{x:Bind}" /> <controls:DayColumnControl DayModel="{x:Bind}" />
@@ -69,11 +68,7 @@
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<!-- TODO: Make aot safe. --> <toolkitControls:UniformGrid Orientation="Horizontal" Rows="1" />
<toolkitControls:UniformGrid
Columns="{Binding CalendarRenderOptions.TotalDayCount}"
Orientation="Horizontal"
Rows="1" />
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
</ItemsControl> </ItemsControl>
@@ -103,18 +98,16 @@
<!-- Each vertical day grids that renders events. --> <!-- Each vertical day grids that renders events. -->
<ItemsControl <ItemsControl
x:Name="EventGridsItemsControl"
Grid.Column="1" Grid.Column="1"
HorizontalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
ItemTemplate="{StaticResource DayCalendarItemVerticalRenderTemplate}" ItemTemplate="{StaticResource DayCalendarItemVerticalRenderTemplate}"
ItemsSource="{x:Bind CalendarDays}"> ItemsSource="{x:Bind CalendarDays}"
Loaded="OnEventGridsItemsControlLoaded">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<!-- TODO: Make AOT SAFE. --> <toolkitControls:UniformGrid Orientation="Horizontal" Rows="1" />
<toolkitControls:UniformGrid
Columns="{Binding CalendarRenderOptions.TotalDayCount}"
Orientation="Horizontal"
Rows="1" />
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
</ItemsControl> </ItemsControl>
@@ -1,4 +1,8 @@
using Microsoft.UI.Xaml; using CommunityToolkit.WinUI.Controls;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Wino.Calendar.Controls;
using Wino.Core.Domain.Models.Calendar;
namespace Wino.Styles; namespace Wino.Styles;
@@ -8,4 +12,38 @@ public sealed partial class WinoCalendarResources : ResourceDictionary
{ {
this.InitializeComponent(); this.InitializeComponent();
} }
private void OnRegularEventItemsControlLoaded(object sender, RoutedEventArgs e)
{
if (sender is ItemsControl itemsControl && itemsControl.DataContext is CalendarDayModel dayModel)
{
if (itemsControl.ItemsPanelRoot is WinoCalendarPanel panel)
{
panel.HourHeight = dayModel.CalendarRenderOptions.CalendarSettings.HourHeight;
panel.Period = dayModel.Period;
}
}
}
private void OnDayColumnsItemsControlLoaded(object sender, RoutedEventArgs e)
{
if (sender is ItemsControl itemsControl && itemsControl.DataContext is DayRangeRenderModel rangeModel)
{
if (itemsControl.ItemsPanelRoot is UniformGrid uniformGrid)
{
uniformGrid.Columns = rangeModel.CalendarRenderOptions.TotalDayCount;
}
}
}
private void OnEventGridsItemsControlLoaded(object sender, RoutedEventArgs e)
{
if (sender is ItemsControl itemsControl && itemsControl.DataContext is DayRangeRenderModel rangeModel)
{
if (itemsControl.ItemsPanelRoot is UniformGrid uniformGrid)
{
uniformGrid.Columns = rangeModel.CalendarRenderOptions.TotalDayCount;
}
}
}
} }