Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
85c47e3
Remove .NET 8 specific code for templates (#30342)
jfversluis Jul 1, 2025
1df60b8
[Catalyst] Fix Scrollbar does not align with FlowDirection change in …
devanathan-vaithiyanathan Jul 1, 2025
fa58c97
[Android] Fix for OnSizeAllocated is not reported for Android AppShel…
BagavathiPerumal Jul 1, 2025
f87e5f3
Permissions (BT & WiFi): don't add AccessFineLocation to required per…
janusw Jul 1, 2025
f71da1d
Fixed the RealParent Warning shown issue (#30156)
Ahamed-Ali Jul 2, 2025
ee6c172
[iOS/MacCatalyst] Fix: Setting SelectedItem Programmatically and Then…
bhavanesh2001 Jul 2, 2025
fbf3af7
[Windows] Fixed StackLayout crashes on Windows with HeightRequest as …
Dhivya-SF4094 Jul 3, 2025
82f21a4
[Windows] Fixed CanvasDrawingSession Exception on Clipping Image (#30…
SubhikshaSf4851 Jul 3, 2025
61fe795
[Testing] Feature matrix UITest Cases for ScrollView Control (#30188)
NafeelaNazhir Jul 3, 2025
d056e02
[Testing] Feature Matrix UITest Cases for TimePicker Control (#30271)
TamilarasanSF4853 Jul 3, 2025
2b87456
[Catalyst] Adding and Removing ContextMenus currently does not work -…
kubaflo Jul 3, 2025
7228eca
Fix for TapGestureRecognizer ButtonMask always return 0 (#30372)
HarishwaranVijayakumar Jul 3, 2025
73d8966
fix extention typo (#30461)
SimonCropp Jul 10, 2025
838273e
fix some incorrect casting using `as` (#30459)
SimonCropp Jul 10, 2025
3c59cd2
[Testing] Feature Matrix UITest Cases for SearchBar Control (#30398)
TamilarasanSF4853 Jul 10, 2025
9bd6e4e
[Testing] Feature Matrix UITest Cases for DatePicker Control (#30159)
TamilarasanSF4853 Jul 10, 2025
b111dc7
[create-pull-request] automated change (#30591)
github-actions[bot] Jul 14, 2025
1c13fe9
[Testing] Add UITest for Issue30147 on iOS (#30506)
devanathan-vaithiyanathan Jul 17, 2025
18b161f
[Android] Fix for Search Handler visual and functional bug in subtabs…
BagavathiPerumal Jul 17, 2025
cc45d6f
[Windows] Fixed the Pasted Password Becomes Visible When IsPassword I…
Ahamed-Ali Jul 17, 2025
4004fdf
[Testing] Fixed Test case failure in PR 30696 - [07/21/2025] Candidat…
TamilarasanSF4853 Jul 20, 2025
828a4e8
[Testing] Fixed Test case LabelShouldSizeProperlyOnCollectionView fai…
TamilarasanSF4853 Jul 21, 2025
29833be
[Testing] Fixed Test case LabelShouldSizeProperlyOnCollectionView fai…
TamilarasanSF4853 Jul 24, 2025
96e9a51
[Testing] Fixed Test cases TimePickerFeatureTests failure in PR 30696…
TamilarasanSF4853 Jul 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected override void OnApplyTemplate()
{
base.OnApplyTemplate();

_icon = (GetTemplateChild(ElementIcon) as View)!;
_icon = (View)GetTemplateChild(ElementIcon);
_icon.WidthRequest = Width;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public IndicatorCodeGallery()
generator.GenerateItems();

_carouselView.PropertyChanged += CarouselViewPropertyChanged;
(_carouselView.ItemsSource as ObservableCollection<CollectionViewGalleryTestItem>)!.CollectionChanged += IndicatorCodeGalleryCollectionChanged;
((ObservableCollection<CollectionViewGalleryTestItem>)_carouselView.ItemsSource).CollectionChanged += IndicatorCodeGalleryCollectionChanged;

var indicatorView = new IndicatorView
{
Expand Down Expand Up @@ -205,7 +205,7 @@ public IndicatorCodeGallery()
Padding = new Thickness(5),
Command = new Command(() =>
{
var items = (_carouselView.ItemsSource as ObservableCollection<CollectionViewGalleryTestItem>)!;
var items = (ObservableCollection<CollectionViewGalleryTestItem>)_carouselView.ItemsSource;
items.Remove(items[0]);
})
};
Expand Down Expand Up @@ -238,7 +238,7 @@ public IndicatorCodeGallery()
_carouselView.Position++;
}, () =>
{
var items = (_carouselView.ItemsSource as ObservableCollection<CollectionViewGalleryTestItem>)!;
var items = (ObservableCollection<CollectionViewGalleryTestItem>)_carouselView.ItemsSource;
return _carouselView.Position < items.Count - 1;
})
};
Expand All @@ -252,7 +252,7 @@ public IndicatorCodeGallery()
Padding = new Thickness(5),
Command = new Command(() =>
{
var items = (_carouselView.ItemsSource as ObservableCollection<CollectionViewGalleryTestItem>)!;
var items = (ObservableCollection<CollectionViewGalleryTestItem>)_carouselView.ItemsSource;
var indexToRemove = items.Count - 1;
items.Remove(items[indexToRemove]);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ItemsSourceGenerator(ItemsView cv, int initialItems = 1000,
button.Clicked += GenerateItems;
WeakReferenceMessenger.Default.Register<ExampleTemplateCarousel, string>(this, "remove", (_, obj) =>
{
(cv.ItemsSource as ObservableCollection<CollectionViewGalleryTestItem>)!.Remove((obj.BindingContext as CollectionViewGalleryTestItem)!);
((ObservableCollection<CollectionViewGalleryTestItem>)cv.ItemsSource).Remove((obj.BindingContext as CollectionViewGalleryTestItem)!);
});

Content = layout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ObservableCodeCollectionViewGallery(ItemsLayoutOrientation orientation =

IItemsLayout itemsLayout = grid
? new GridItemsLayout(3, orientation)
: new LinearItemsLayout(orientation) as IItemsLayout;
: new LinearItemsLayout(orientation);

var itemTemplate = ExampleTemplates.PhotoTemplate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ObservableCollectionResetGallery()
}
};

var itemsLayout = new GridItemsLayout(3, ItemsLayoutOrientation.Vertical) as IItemsLayout;
IItemsLayout itemsLayout = new GridItemsLayout(3, ItemsLayoutOrientation.Vertical);

var itemTemplate = ExampleTemplates.PhotoTemplate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public ObservableMultiItemCollectionViewGallery(ItemsLayoutOrientation orientati
}
};

var itemsLayout = grid
IItemsLayout itemsLayout = grid
? new GridItemsLayout(3, orientation)
: new LinearItemsLayout(orientation) as IItemsLayout;
: new LinearItemsLayout(orientation);

var itemTemplate = ExampleTemplates.PhotoTemplate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected override async void OnAppearing()

void OnItemsUpdatingScrollModeChanged(object sender, EventArgs e)
{
CollectionView.ItemsUpdatingScrollMode = (ItemsUpdatingScrollMode)(sender! as EnumPicker)!.SelectedItem;
CollectionView.ItemsUpdatingScrollMode = (ItemsUpdatingScrollMode)((EnumPicker)sender!).SelectedItem;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected override void OnAppearing()

private void OnDragStarting(object sender, DragStartingEventArgs e)
{
var boxView = (View)(sender as Element)!.Parent;
var boxView = (View)((Element)sender)!.Parent;
DragStartingTitle.IsVisible = true;
DragStartingPositionLabel.Text = $"- Self X:{(int)e.GetPosition(boxView)!.Value.X}, Y:{(int)e.GetPosition(boxView)!.Value.Y}";
DragStartingScreenPositionLabel.Text = $"- Screen X:{(int)e.GetPosition(null)!.Value.X}, Y:{(int)e.GetPosition(null)!.Value.Y}";
Expand All @@ -54,7 +54,7 @@ private void OnDragStarting(object sender, DragStartingEventArgs e)

private void OnDropCompleted(object sender, DropCompletedEventArgs e)
{
var sl = (sender as Element)!.Parent as StackLayout;
var sl = ((Element)sender).Parent as StackLayout;

if (sl == SLAllColors)
SLRainbow.Background = SolidColorBrush.White;
Expand All @@ -65,7 +65,7 @@ private void OnDropCompleted(object sender, DropCompletedEventArgs e)

private void OnDragOver(object sender, DragEventArgs e)
{
var sl = (StackLayout)(sender as Element)!.Parent;
var sl = (StackLayout)((Element)sender).Parent;

if (!e.Data.Properties.ContainsKey("Source"))
return;
Expand All @@ -86,7 +86,7 @@ private void OnDragOver(object sender, DragEventArgs e)

private void OnDragLeave(object sender, DragEventArgs e)
{
var sl = (StackLayout)(sender as Element)!.Parent;
var sl = (StackLayout)((Element)sender).Parent;

if (!e.Data.Properties.ContainsKey("Source"))
return;
Expand All @@ -107,7 +107,7 @@ private void OnDragLeave(object sender, DragEventArgs e)

private void OnDrop(object sender, DropEventArgs e)
{
var sl = (sender as Element)!.Parent as StackLayout;
var sl = ((Element)sender).Parent as StackLayout;

if (!e.Data.Properties.ContainsKey("Source"))
return;
Expand All @@ -122,7 +122,7 @@ private void OnDrop(object sender, DropEventArgs e)
DropScreenPositionLabel.Text = $"- Screen: X:{(int)e.GetPosition(null)!.Value.X}, Y:{(int)e.GetPosition(null)!.Value.Y}";
DropRelativePositionLabel.Text = $"- This label: X:{(int)e.GetPosition(DropRelativePositionLabel)!.Value.X}, Y:{(int)e.GetPosition(DropRelativePositionLabel)!.Value.Y}";

var color = (e.Data.Properties["Color"] as SolidColorBrush)!;
var color = (SolidColorBrush)e.Data.Properties["Color"];

if (AllColors.Contains(color))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void SwapRoot(object sender, EventArgs e)
}
else
{
(Parent as IStackNavigationView)!.RequestNavigation(
((IStackNavigationView)Parent).RequestNavigation(
new NavigationRequest(_currentNavStack, true));

_currentNavStack = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public LargeTitlesPageiOS()
{
Text = "Tooggle UseLargeTitles on Navigation",
Command = new Command( () =>{
var navPage = (Parent as NavigationPage)!;
var navPage = (NavigationPage)Parent;
navPage.On<iOS>().SetPrefersLargeTitles(!navPage.On<iOS>().PrefersLargeTitles());
} )
},
Expand All @@ -54,7 +54,7 @@ public LargeTitlesPageiOS()
{
Text = "UseLargeTitles on Navigation with safe Area",
Command = new Command( () =>{
var navPage = (Parent as NavigationPage)!;
var navPage = (NavigationPage)Parent;
navPage.On<iOS>().SetPrefersLargeTitles(true);
var page = new ContentPage { Title = "New Title", BackgroundColor = Colors.Red };
page.On<iOS>().SetUseSafeArea(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public AndroidSwipeViewTransitionModePage()

void OnSwipeViewTransitionModeChanged(object sender, EventArgs e)
{
SwipeTransitionMode transitionMode = (SwipeTransitionMode)(sender as EnumPicker)!.SelectedItem;
SwipeTransitionMode transitionMode = (SwipeTransitionMode)((EnumPicker)sender).SelectedItem;
swipeView.On<Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetSwipeTransitionMode(transitionMode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void OnParentPagePropertyChanged(BindableObject element, object oldValue,
if (newValue != null)
{
var enumType = typeof(CollapseStyle);
var instance = (element as WindowsCollapseStyleChangerPage)!;
var instance = (WindowsCollapseStyleChangerPage)element;
instance.picker.SelectedIndex = Array.IndexOf(Enum.GetNames(enumType), Enum.GetName(enumType, instance.ParentPage.On<Microsoft.Maui.Controls.PlatformConfiguration.Windows>().GetCollapseStyle()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static void OnParentPagePropertyChanged(BindableObject element, object oldValue,
{
if (newValue != null)
{
var instance = element as WindowsCollapseWidthAdjusterPage;
var instance = (WindowsCollapseWidthAdjusterPage)element;
instance!.entry.Text = instance.ParentPage.On<Microsoft.Maui.Controls.PlatformConfiguration.Windows>().CollapsedPaneWidth().ToString();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ static void OnParentPagePropertyChanged(BindableObject element, object oldValue,
if (newValue != null)
{
var enumType = typeof(ToolbarPlacement);
var instance = element as WindowsToolbarPlacementChangerPage;
instance!.picker.SelectedIndex = Array.IndexOf(Enum.GetNames(enumType), Enum.GetName(enumType, instance.ParentPage.On<Microsoft.Maui.Controls.PlatformConfiguration.Windows>().GetToolbarPlacement()));
var instance = (WindowsToolbarPlacementChangerPage)element;
instance.picker.SelectedIndex = Array.IndexOf(Enum.GetNames(enumType), Enum.GetName(enumType, instance.ParentPage.On<Microsoft.Maui.Controls.PlatformConfiguration.Windows>().GetToolbarPlacement()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public iOSSafeAreaPage()
void OnButtonClicked(object sender, EventArgs e)
{
On<iOS>().SetUseSafeArea(false);
(sender as Button)!.IsEnabled = false;
((Button)sender).IsEnabled = false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,7 @@ bool UpdateContentPadding()
// and propagate any margins set
if (_contentView?.PlatformView != null)
{
var dpWidth = _rootView.Context.FromPixels(_contentView.PlatformView.MeasuredWidth);
var dpHeight = _rootView.Context.FromPixels(_contentView.PlatformView.MeasuredHeight);
_contentView.View.Frame = _contentView.View.ComputeFrame(new Graphics.Rect(0, 0, dpWidth, dpHeight));
SetContentViewFrame();

cl.LeftMargin = (int)_rootView.Context.ToPixels(viewMargin.Left);
cl.TopMargin = (int)_rootView.Context.ToPixels(viewMargin.Top);
Expand All @@ -434,6 +432,13 @@ bool UpdateContentPadding()
return returnValue;
}

void SetContentViewFrame()
{
var dpWidth = _rootView.Context.FromPixels(_contentView.PlatformView.MeasuredWidth);
var dpHeight = _rootView.Context.FromPixels(_contentView.PlatformView.MeasuredHeight);
_contentView.View.Frame = _contentView.View.ComputeFrame(new Graphics.Rect(0, 0, dpWidth, dpHeight));
}

void OnFlyoutViewLayoutChanging()
{
// The second time this fires the non flyout part of the view
Expand Down Expand Up @@ -464,6 +469,12 @@ void OnFlyoutViewLayoutChanging()
UpdateFooterLayout();
UpdateContentPadding();
}
else if (_contentView?.PlatformView is not null &&
((_contentView.PlatformView.MeasuredHeight > 0 && _contentView.View.Frame.Width == 0) ||
(_contentView.PlatformView.MeasuredWidth > 0 && _contentView.View.Frame.Height == 0)))
{
SetContentViewFrame();
}
}

void UpdateVerticalScrollMode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace Microsoft.Maui.Controls.Platform.Compatibility
{
public class ShellToolbarTracker : Java.Lang.Object, AView.IOnClickListener, IShellToolbarTracker, IFlyoutBehaviorObserver
{
const int _placeholderMenuItemId = 100;
#region IFlyoutBehaviorObserver

void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
Expand Down Expand Up @@ -632,7 +633,6 @@ protected virtual void UpdateTitleView(Context context, AToolbar toolbar, View t
private void UpdateToolbarItemsTintColors(AToolbar toolbar)
{
var menu = toolbar.Menu;
int _placeholderMenuItemId = 100;
if (menu.FindItem(_placeholderMenuItemId) is IMenuItem item)
{
using (var icon = item.Icon)
Expand All @@ -643,7 +643,6 @@ private void UpdateToolbarItemsTintColors(AToolbar toolbar)
protected virtual void UpdateToolbarItems(AToolbar toolbar, Page page)
{
var menu = toolbar.Menu;
int _placeholderMenuItemId = 100;
SearchHandler = Shell.GetSearchHandler(page);
if (SearchHandler != null && SearchHandler.SearchBoxVisibility != SearchBoxVisibility.Hidden)
{
Expand All @@ -662,6 +661,8 @@ protected virtual void UpdateToolbarItems(AToolbar toolbar, Page page)

if (SearchHandler.SearchBoxVisibility == SearchBoxVisibility.Collapsible)
{
menu.RemoveItem(_placeholderMenuItemId);

var placeholder = new Java.Lang.String(SearchHandler.Placeholder);
var item = menu.Add(0, _placeholderMenuItemId, 0, placeholder);
placeholder.Dispose();
Expand Down
47 changes: 28 additions & 19 deletions src/Controls/src/Core/Element/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,30 +333,39 @@ internal Element ParentOverride
}

WeakReference<Element> _realParent;
/// <summary>For internal use by .NET MAUI.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public Element RealParent
Element TryGetRealParent(bool logWarningIfParentHasBeenCollected = true)
{
get
var realParent = _realParent;
if (realParent is null)
{
if (_realParent is null)
{
return null;
}
if (_realParent.TryGetTarget(out var parent))
{
return parent;
}
else
return null;
}
if (realParent.TryGetTarget(out var parent))
{
return parent;
}
else
{
// Clear the weak reference since the target has been garbage collected
// This prevents repeated checks and warnings on subsequent accesses
_realParent = null;
if (logWarningIfParentHasBeenCollected)
{
Application.Current?
.FindMauiContext()?
.CreateLogger<Element>()?
.LogWarning($"The RealParent on {this} has been Garbage Collected. This should never happen. Please log a bug: https://github.com/dotnet/maui");
.FindMauiContext()?
.CreateLogger<Element>()?
.LogWarning($"The RealParent on {this} has been Garbage Collected. This should never happen. Please log a bug: https://github.com/dotnet/maui");
}

return null;
}

return null;
}

/// <summary>For internal use by .NET MAUI.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public Element RealParent
{
get => TryGetRealParent();
private set
{
if (value is null)
Expand Down Expand Up @@ -386,7 +395,7 @@ public Element Parent

void SetParent(Element value)
{
Element realParent = RealParent;
Element realParent = TryGetRealParent(false);

if (realParent == value)
{
Expand Down
Loading
Loading