forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Style issues Layout was applied on the content and not the visual first child Fix: typo Shared project fix Xml-Tag Fix for issue xamarin#7671 Style issues Layout was applied on the content and not the visual first child Fix: typo
- Loading branch information
1 parent
a7b30d8
commit 4be8ddb
Showing
6 changed files
with
105 additions
and
17 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7671.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:d="http://xamarin.com/schemas/2014/forms/design" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
x:Class="Xamarin.Forms.Controls.Issues.Issue7671"> | ||
<ContentPage.Content> | ||
<StackLayout> | ||
<Label Text="Welcome to Xamarin.Forms!" | ||
VerticalOptions="CenterAndExpand" | ||
HorizontalOptions="CenterAndExpand" /> | ||
</StackLayout> | ||
</ContentPage.Content> | ||
<ContentPage.ControlTemplate> | ||
<ControlTemplate> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="60" /> | ||
<RowDefinition /> | ||
<RowDefinition Height="60" /> | ||
</Grid.RowDefinitions> | ||
|
||
<Frame Grid.Row="0" BackgroundColor="Green"> | ||
<Label Text="I am the template." /> | ||
</Frame> | ||
<ContentPresenter Grid.Row="1" /> | ||
<Frame Grid.Row="2" BackgroundColor="Red"> | ||
<Label Text="I am the template." /> | ||
</Frame> | ||
</Grid> | ||
</ControlTemplate> | ||
</ContentPage.ControlTemplate> | ||
</ContentPage> |
24 changes: 24 additions & 0 deletions
24
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7671.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Xamarin.Forms; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
using Xamarin.Forms.Xaml; | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.None, 7671, "Check ControlTemplate rendering", PlatformAffected.WPF)] | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class Issue7671 : ContentPage | ||
{ | ||
public Issue7671() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
namespace Xamarin.Forms.Platform.WPF.Controls | ||
using System; | ||
using System.Windows; | ||
using WpfSize = System.Windows.Size; | ||
|
||
namespace Xamarin.Forms.Platform.WPF.Controls | ||
{ | ||
public class FormsContentPage : FormsPage | ||
{ | ||
public FormsContentPage() | ||
{ | ||
this.DefaultStyleKey = typeof(FormsContentPage); | ||
} | ||
|
||
static FormsContentPage() | ||
{ | ||
DefaultStyleKeyProperty.OverrideMetadata(typeof(FormsContentPage), new FrameworkPropertyMetadata(typeof(FormsContentPage))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using Xamarin.Forms.Platform.WPF.Controls; | ||
|
||
namespace Xamarin.Forms.Platform.WPF | ||
{ | ||
public class PageRenderer : VisualPageRenderer<Page, FormsContentPage> | ||
{ | ||
VisualElement _currentView; | ||
VisualElement _currentView = null; | ||
|
||
protected override void OnElementChanged(ElementChangedEventArgs<Page> e) | ||
{ | ||
if (e.NewElement != null) | ||
{ | ||
if (Control == null) // construct and SetNativeControl and suscribe control event | ||
{ | ||
if (Control == null) | ||
SetNativeControl(new FormsContentPage()); | ||
} | ||
|
||
// Update control property | ||
UpdateContent(); | ||
} | ||
|
||
base.OnElementChanged(e); | ||
} | ||
|
||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) | ||
{ | ||
base.OnElementPropertyChanged(sender, e); | ||
|
||
if (e.PropertyName == ContentPage.ContentProperty.PropertyName) | ||
|
||
if (e.PropertyName == ContentPage.ContentProperty.PropertyName | ||
|| e.PropertyName == TemplatedPage.ControlTemplateProperty.PropertyName) | ||
{ | ||
UpdateContent(); | ||
} | ||
} | ||
|
||
void UpdateContent() | ||
{ | ||
ContentPage page = Element as ContentPage; | ||
if (page != null) | ||
if (Element is ContentPage page) | ||
{ | ||
if (_currentView != null) | ||
if (_currentView != null) // destroy current view | ||
{ | ||
_currentView.Cleanup(); // cleanup old view | ||
_currentView?.Cleanup(); | ||
_currentView = null; | ||
} | ||
|
||
_currentView = page.Content; | ||
_currentView = page.LogicalChildren.OfType<VisualElement>().FirstOrDefault() ?? page.Content; | ||
Control.Content = _currentView != null ? Platform.GetOrCreateRenderer(_currentView).GetNativeElement() : null; | ||
} | ||
} | ||
} | ||
} | ||
} |