Skip to content

Commit d7e6337

Browse files
committed
1 parent 82d823a commit d7e6337

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<ContentPage
2+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Maui.Controls.Sample.DetailPage"
5+
Title="Detail"
6+
xmlns:local="clr-namespace:Maui.Controls.Sample">
7+
<!--<Grid>
8+
<Grid.RowDefinitions>
9+
<RowDefinition Height="50" />
10+
<RowDefinition Height="50" />
11+
<RowDefinition Height="50" />
12+
<RowDefinition Height="50" />
13+
</Grid.RowDefinitions>
14+
<Entry Text='Hii'
15+
Grid.Row="0"
16+
ClearButtonVisibility="WhileEditing" />
17+
<DatePicker Date="06/21/2022"
18+
Grid.Row="1" />
19+
<CheckBox IsChecked="True"
20+
Grid.Row="2" />
21+
<Button Text="Click"
22+
Grid.Row="3"
23+
Clicked="Button_Clicked" />
24+
</Grid>-->
25+
</ContentPage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Microsoft.Maui.Controls;
2+
using Microsoft.Maui.Graphics;
3+
4+
namespace Maui.Controls.Sample
5+
{
6+
public partial class DetailPage : ContentPage
7+
{
8+
public DetailPage()
9+
{
10+
InitializeComponent();
11+
}
12+
13+
//void Button_Clicked(System.Object sender, System.EventArgs e)
14+
//{
15+
// Application.Current.UserAppTheme = AppTheme.Dark;
16+
//}
17+
}
18+
}

src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs

+31
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ protected override void Dispose(bool disposing)
4646
_footerViewFormsElement.MeasureInvalidated -= OnFormsElementMeasureInvalidated;
4747
}
4848

49+
if (_headerUIView is MauiView hv)
50+
{
51+
hv.LayoutChanged += HeaderView_LayoutChanged;
52+
}
53+
54+
if (_footerUIView is MauiView fv)
55+
{
56+
fv.LayoutChanged -= FooterView_LayoutChanged;
57+
}
58+
4959
_headerUIView = null;
5060
_headerViewFormsElement = null;
5161
_footerUIView = null;
@@ -105,15 +115,26 @@ internal void UpdateFooterView()
105115
UpdateSubview(ItemsView?.Footer, ItemsView?.FooterTemplate, FooterTag,
106116
ref _footerUIView, ref _footerViewFormsElement);
107117
UpdateHeaderFooterPosition();
118+
119+
if (_footerUIView is MauiView mv)
120+
{
121+
mv.LayoutChanged += FooterView_LayoutChanged;
122+
}
108123
}
109124

110125
internal void UpdateHeaderView()
111126
{
112127
UpdateSubview(ItemsView?.Header, ItemsView?.HeaderTemplate, HeaderTag,
113128
ref _headerUIView, ref _headerViewFormsElement);
114129
UpdateHeaderFooterPosition();
130+
131+
if(_headerUIView is MauiView mv)
132+
{
133+
mv.LayoutChanged += HeaderView_LayoutChanged;
134+
}
115135
}
116136

137+
117138
internal void UpdateSubview(object view, DataTemplate viewTemplate, nint viewTag, ref UIView uiView, ref VisualElement formsElement)
118139
{
119140
uiView?.RemoveFromSuperview();
@@ -239,5 +260,15 @@ internal void UpdateLayoutMeasurements()
239260
if (_footerViewFormsElement != null)
240261
HandleFormsElementMeasureInvalidated(_footerViewFormsElement);
241262
}
263+
264+
private void HeaderView_LayoutChanged(object sender, EventArgs e)
265+
{
266+
HandleFormsElementMeasureInvalidated(_headerViewFormsElement);
267+
}
268+
269+
private void FooterView_LayoutChanged(object sender, EventArgs e)
270+
{
271+
HandleFormsElementMeasureInvalidated(_footerViewFormsElement);
272+
}
242273
}
243274
}

src/Core/src/Platform/iOS/MauiView.cs

+9
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public override void LayoutSubviews()
134134
}
135135

136136
CrossPlatformArrange(bounds);
137+
OnLayoutChanged();
137138
}
138139

139140
public override void SetNeedsLayout()
@@ -174,5 +175,13 @@ public override void MovedToWindow()
174175
base.MovedToWindow();
175176
_movedToWindow?.Invoke(this, EventArgs.Empty);
176177
}
178+
179+
[UnconditionalSuppressMessage("Memory", "MEM0001", Justification = IUIViewLifeCycleEvents.UnconditionalSuppressMessage)]
180+
internal event EventHandler? LayoutChanged;
181+
182+
private void OnLayoutChanged()
183+
{
184+
LayoutChanged?.Invoke(this, EventArgs.Empty);
185+
}
177186
}
178187
}

0 commit comments

Comments
 (0)