<Compile Include="_2489CustomRenderer.cs" />
<Compile Include="_57114Renderer.cs" />
<Compile Include="_58406EffectRenderer.cs" />
+ <Compile Include="_5886DependencyService.cs" />
<Compile Include="_60122ImageRenderer.cs" />
<Content Include="Assets\Fonts\OFL.txt" />
<Content Include="bank.png" />
--- /dev/null
+using Xamarin.Forms;
+using Xamarin.Forms.ControlGallery.WindowsUniversal;
+using Xamarin.Forms.Platform.UWP;
+using static Xamarin.Forms.Controls.Issues.Issue5886;
+
+[assembly: Dependency(typeof(MyInterfaceImplementation))]
+namespace Xamarin.Forms.ControlGallery.WindowsUniversal
+{
+ public class MyInterfaceImplementation : IReplaceUWPRendererService
+ {
+ public MyInterfaceImplementation()
+ {
+ }
+
+ public void ConvertToNative(View formsView)
+ {
+ var renderer = Xamarin.Forms.Platform.UWP.Platform.GetRenderer(formsView);
+ if (renderer != null)
+ {
+ renderer.Dispose();
+ Platform.UWP.Platform.SetRenderer(formsView, null);
+ }
+
+ var newRenderer = formsView.GetOrCreateRenderer();
+ }
+
+ public void CreateRenderer(View formsView)
+ {
+ var newRenderer = formsView.GetOrCreateRenderer();
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+#if UITEST
+using NUnit.Framework;
+using Xamarin.Forms.Core.UITests;
+using System.Linq;
+#endif
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Controls.Issues
+{
+#if UITEST
+ [Category(UITestCategories.Layout)]
+#endif
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Github, 5886, "Value does not fall with in the expected range Exception while creating NativeView Xamarin Forms UWP", PlatformAffected.UWP)]
+ public class Issue5886 : TestContentPage
+ {
+ public interface IReplaceUWPRendererService
+ {
+ void ConvertToNative(View formsView);
+ void CreateRenderer(View formsView);
+ }
+
+ ScrollView scrollView;
+ Label label;
+ Button button0;
+ Button button1;
+ protected override void Init()
+ {
+ scrollView = new ScrollView();
+
+ var grid = new Grid();
+ grid.Children.Add(new Label { Text = "Discard Draft ?" });
+
+ scrollView.Content = grid;
+
+ button0 = new Button
+ {
+ Text = "Create native renderer",
+ AutomationId = "Step1"
+ };
+
+ button0.Clicked += Button_Clicked1;
+
+ button1 = new Button
+ {
+ Text = "Start native view conversion",
+ AutomationId = "Step2",
+ IsVisible = false
+ };
+
+ button1.Clicked += Button_Clicked;
+
+ label = new Label
+ {
+ Text = "You should be able to push first the top button, then the bottom without any exception (Element is already the child of another element.)",
+ AutomationId = "ResultLabel"
+ };
+
+ var stack = new StackLayout();
+ stack.Children.Add(button0);
+ stack.Children.Add(button1);
+ stack.Children.Add(label);
+
+ Content = stack;
+ }
+
+ void Button_Clicked(object sender, EventArgs e)
+ {
+ DependencyService.Get<IReplaceUWPRendererService>().ConvertToNative(this.scrollView);
+ label.Text = "Step 2 OK";
+ }
+
+ void Button_Clicked1(object sender, EventArgs e)
+ {
+ DependencyService.Get<IReplaceUWPRendererService>().CreateRenderer(this.scrollView);
+ label.Text = "Step 1 OK";
+ button1.IsVisible = true;
+ }
+
+#if UITEST && __WINDOWS__
+ [Test]
+ public void ReplaceRenderer()
+ {
+ RunningApp.WaitForElement("Step1");
+ RunningApp.Tap("Step1");
+
+ RunningApp.WaitForElement("Step2");
+ RunningApp.Tap("Step2");
+
+ var resultLabel = RunningApp.Query("ResultLabel").FirstOrDefault();
+
+ Assert.AreEqual("Step 2 OK", resultLabel.Description);
+ }
+#endif
+ }
+}
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla59172.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FlagTestHelpers.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Issue5886.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue6260.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue5766.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CollectionViewBoundMultiSelection.cs" />
<Compile Update="$(MSBuildThisFileDirectory)Issue6644.xaml.cs">
<DependentUpon>Issue6644.xaml</DependentUpon>
</Compile>
+ <Compile Update="$(MSBuildThisFileDirectory)Issue6254.xaml.cs">
+ <DependentUpon>Issue6254.xaml</DependentUpon>
+ </Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue5268.xaml">
ClearMasterDetailToggle();
return;
}
- if (!CurrentMasterDetailPage.ShouldShowToolbarButton() || CurrentMasterDetailPage.Master.IconImageSource.IsEmpty ||
+ if (!CurrentMasterDetailPage.ShouldShowToolbarButton() || (CurrentMasterDetailPage.Master.IconImageSource?.IsEmpty ?? true) ||
(MasterDetailPageController.ShouldShowSplitMode && CurrentMasterDetailPage.IsPresented))
{
//clear out existing icon;
element.LayoutUpdated -= SetInitialRtlPosition;
}
}
+
+ if (_currentView != null)
+ _currentView.Cleanup();
}
protected override void OnElementChanged(ElementChangedEventArgs<ScrollView> e)
var handler = new PropertyChangedEventHandler(OnMenuItemPropertyChanged);
_tableView = tableView;
- SetupSelection(tableView);
if (_cell != null)
{
return null;
}
- static void SetupSelection(UITableView table)
+ internal static void SetupSelection(UITableView table)
{
if (table.GestureRecognizers == null)
return;
}
}
}
-}
\ No newline at end of file
+}
+using System;
using UIKit;
using Xamarin.Forms.Internals;
}
}
+ internal static UIModalPresentationStyle ToNativeModalPresentationStyle(this PlatformConfiguration.iOSSpecific.UIModalPresentationStyle style)
+ {
+ switch (style)
+ {
+ case PlatformConfiguration.iOSSpecific.UIModalPresentationStyle.FormSheet:
+ return UIModalPresentationStyle.FormSheet;
+ case PlatformConfiguration.iOSSpecific.UIModalPresentationStyle.FullScreen:
+ return UIModalPresentationStyle.FullScreen;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(style));
+ }
+ }
+
internal static UIReturnKeyType ToUIReturnKeyType(this ReturnType returnType)
{
switch (returnType)
static bool? s_isiOS9OrNewer;
static bool? s_isiOS10OrNewer;
static bool? s_isiOS11OrNewer;
+ static bool? s_isiOS13OrNewer;
static bool? s_respondsTosetNeedsUpdateOfHomeIndicatorAutoHidden;
static bool? s_isiOS13OrNewer;
#endif
}
}
+ internal static bool IsiOS13OrNewer
+ {
+ get
+ {
+ if (!s_isiOS13OrNewer.HasValue)
+ s_isiOS13OrNewer = UIDevice.CurrentDevice.CheckSystemVersion(13, 0);
+ return s_isiOS13OrNewer.Value;
+ }
+ }
+
internal static bool RespondsToSetNeedsUpdateOfHomeIndicatorAutoHidden
{
get
}
}
}
-}
\ No newline at end of file
+}
_modal = modal;
var elementConfiguration = modal.Element as IElementConfiguration<Page>;
- if (elementConfiguration?.On<PlatformConfiguration.iOS>().ModalPresentationStyle() == PlatformConfiguration.iOSSpecific.UIModalPresentationStyle.FormSheet)
- ModalPresentationStyle = UIKit.UIModalPresentationStyle.FormSheet;
+ var modalPresentationStyle = elementConfiguration?.On<PlatformConfiguration.iOS>()?.ModalPresentationStyle() ?? PlatformConfiguration.iOSSpecific.UIModalPresentationStyle.FullScreen;
+ ModalPresentationStyle = modalPresentationStyle.ToNativeModalPresentationStyle();
View.BackgroundColor = UIColor.White;
View.AddSubview(modal.ViewController.View);
protected ListView List;
protected ITemplatedItemsView<Cell> TemplatedItemsView => List;
bool _isDragging;
+ bool _setupSelection;
bool _selectionFromNative;
bool _disposed;
bool _wasEmpty;
_isDragging = true;
}
+ void SetupSelection(UITableViewCell nativeCell, UITableView tableView)
+ {
+ if (!(nativeCell is ContextActionsCell))
+ return;
+
+ if (_setupSelection)
+ return;
+
+ ContextActionsCell.SetupSelection(tableView);
+
+ _setupSelection = true;
+ }
+
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
Cell cell;
else
throw new NotSupportedException();
+ SetupSelection(nativeCell, tableView);
+
if (List.IsSet(Specifics.SeparatorStyleProperty))
{
if (List.OnThisPlatform().GetSeparatorStyle() == SeparatorStyle.FullWidth)