Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 4d24131

Browse files
authored
[WPF] Fixed the NRE in FormWindow (#11926) fixes #11923
1 parent 132d7b7 commit 4d24131

File tree

4 files changed

+61
-6
lines changed

4 files changed

+61
-6
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using System.Windows;
5+
using Xamarin.Forms.Controls.Issues;
6+
using Xamarin.Forms.Platform.WPF;
7+
8+
namespace Xamarin.Forms.ControlGallery.WPF
9+
{
10+
// To test this issue modify the csproj to modify the Application entry point.
11+
// <StartupObject>Xamarin.Forms.ControlGallery.WPF.Issue11923</StartupObject>
12+
// And uncomment the static Main method.
13+
class Issue11923
14+
{
15+
/*
16+
[STAThread]
17+
static void Main(string[] args)
18+
{
19+
var application = new System.Windows.Application();
20+
Forms.SetFlags("CarouselView_Experimental", "MediaElement_Experimental", "RadioButton_Experimental");
21+
FormsMaps.Init("");
22+
Forms.Init();
23+
var formsApplicationPage = new FormsApplicationPage();
24+
formsApplicationPage.LoadApplication(new Controls.App());
25+
26+
Task.Run(() =>
27+
{
28+
Task.Delay(1000).Wait();
29+
30+
application.Dispatcher.InvokeAsync(() =>
31+
{
32+
var window = new Window()
33+
{
34+
Height = 600,
35+
Width = 600
36+
};
37+
38+
var mainPage = new Issue1();
39+
var formsContentLoader = new FormsContentLoader();
40+
var content = formsContentLoader.LoadContentAsync(window, null, mainPage, new CancellationToken()).Result;
41+
42+
window.Content = content;
43+
window.Show();
44+
});
45+
});
46+
47+
application.Run();
48+
}
49+
*/
50+
}
51+
}

Xamarin.Forms.ControlGallery.WPF/Xamarin.Forms.ControlGallery.WPF.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
1+
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
22
<PropertyGroup>
33
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netcoreapp3.1;net461;</TargetFrameworks>
44
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net461;</TargetFrameworks>
@@ -7,8 +7,8 @@
77
<OutputType>WinExe</OutputType>
88
<UseWPF>true</UseWPF>
99
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
10-
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
11-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
10+
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
11+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1212
</PropertyGroup>
1313
<PropertyGroup>
1414
<NoWarn>$(NoWarn);NU1701</NoWarn>

Xamarin.Forms.Platform.WPF/Controls/FormWindow.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ public void SynchronizeAppBar()
199199
ClearValue(TitleBarTextColorProperty);
200200
}
201201

202-
hamburgerButton.Visibility = CurrentMasterDetailPage != null ? Visibility.Visible : Visibility.Collapsed;
202+
if (hamburgerButton != null)
203+
hamburgerButton.Visibility = CurrentMasterDetailPage != null ? Visibility.Visible : Visibility.Collapsed;
203204

204205
if (CurrentNavigationPage != null)
205206
{

Xamarin.Forms.Platform.WPF/Properties/AssemblyInfo.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Windows;
1+
using System.Reflection;
2+
using System.Windows;
23
using Xamarin.Forms;
34
using Xamarin.Forms.Platform.WPF;
45
using Xamarin.Forms.Shapes;
@@ -71,4 +72,6 @@
7172

7273
// Others
7374
[assembly: Xamarin.Forms.Dependency(typeof(ResourcesProvider))]
74-
[assembly: Xamarin.Forms.Dependency(typeof(Deserializer))]
75+
[assembly: Xamarin.Forms.Dependency(typeof(Deserializer))]
76+
77+
[assembly: AssemblyVersion("2.0.0.0")]

0 commit comments

Comments
 (0)