Merge remote-tracking branch 'origin/master' into dev/split-controls

This commit is contained in:
michael-hawker 2021-01-19 15:05:24 -08:00
Родитель e8ff46279b 147000a4fe
Коммит 70de6df1a0
1 изменённых файлов: 20 добавлений и 11 удалений

Просмотреть файл

@ -195,8 +195,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
{
try
{
var pageInstance = Activator.CreateInstance(CurrentSample.PageType);
SampleContent.Content = pageInstance;
SamplePage = Activator.CreateInstance(CurrentSample.PageType) as Page;
SampleContent.Content = SamplePage;
// Some samples use the OnNavigatedTo and OnNavigatedFrom
// Can't use Frame here because some samples depend on the current Frame
@ -206,7 +206,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
if (method != null)
{
method.Invoke(pageInstance, new object[] { e });
method.Invoke(SamplePage, new object[] { e });
}
}
catch
@ -348,6 +348,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
private void SamplePage_Loaded(object sender, RoutedEventArgs e)
{
SamplePage.Loaded -= SamplePage_Loaded;
if (CurrentSample != null && CurrentSample.HasXAMLCode)
{
_lastRenderedProperties = true;
@ -516,17 +518,23 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
if (CurrentSample.HasType)
{
root = SamplePage?.FindDescendantByName("XamlRoot");
}
if (root is Panel)
{
// If we've defined a 'XamlRoot' element to host us as a panel, use that.
(root as Panel).Children.Clear();
(root as Panel).Children.Add(element);
if (root is Panel)
{
// If we've defined a 'XamlRoot' element to host us as a panel, use that.
(root as Panel).Children.Clear();
(root as Panel).Children.Add(element);
}
else
{
// if we didn't find a XamlRoot host, then we replace the entire content of
// the provided sample page with the XAML.
SamplePage.Content = element;
}
}
else
{
// Otherwise, just replace the entire page's content
// Otherwise, just replace our entire presenter's content
SampleContent.Content = element;
}
@ -675,7 +683,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
}
}
private Page SamplePage => SampleContent.Content as Page;
// The Loaded Instance of the backing .xaml.cs Page (if any)
private Page SamplePage { get; set; }
private bool CanChangePaneState => !_onlyDocumentation;