private async void InfoAreaPivot_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (InfoAreaPivot.SelectedItem == PropertiesPivotItem) { return; } if (_currentSample == null) { return; } if (_currentSample.HasXAMLCode) { XamlCodeRenderer.XamlSource = _currentSample.UpdatedXamlCode; } if (_currentSample.HasCSharpCode) { CSharpCodeRenderer.CSharpSource = await _currentSample.GetCSharpSourceAsync(); } if (_currentSample.HasJavaScriptCode) { JavaScriptCodeRenderer.JavaScriptSource = await _currentSample.GetJavaScriptSourceAsync(); } }
public async Task NavigateToSampleAsync(Sample sample) { var pageType = Type.GetType("Microsoft.Toolkit.Uwp.SampleApp.SamplePages." + sample.Type); if (pageType != null) { InfoAreaPivot.Items.Clear(); ShowInfoArea(); var propertyDesc = await sample.GetPropertyDescriptorAsync(); DataContext = sample; Title.Text = sample.Name; NavigationFrame.Navigate(pageType, propertyDesc); _currentSample = sample; if (propertyDesc != null && propertyDesc.Options.Count > 0) { InfoAreaPivot.Items.Add(PropertiesPivotItem); } if (sample.HasXAMLCode) { XamlCodeRenderer.XamlSource = _currentSample.UpdatedXamlCode; InfoAreaPivot.Items.Add(XamlPivotItem); InfoAreaPivot.SelectedIndex = 0; } if (sample.HasCSharpCode) { CSharpCodeRenderer.CSharpSource = await _currentSample.GetCSharpSourceAsync(); InfoAreaPivot.Items.Add(CSharpPivotItem); } if (sample.HasJavaScriptCode) { JavaScriptCodeRenderer.CSharpSource = await _currentSample.GetJavaScriptSourceAsync(); InfoAreaPivot.Items.Add(JavaScriptPivotItem); } UpdateRootGridMinWidth(); } }
private async void InfoAreaPivot_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (InfoAreaPivot.SelectedItem != null) { var sample = DataContext as Sample; if (sample != null) { TrackingManager.TrackEvent("PropertyGrid", (InfoAreaPivot.SelectedItem as FrameworkElement)?.Name, sample.Name); } } if (InfoAreaPivot.SelectedItem == PropertiesPivotItem) { return; } if (_currentSample == null) { return; } if (_currentSample.HasXAMLCode) { XamlCodeRenderer.XamlSource = _currentSample.UpdatedXamlCode; } if (_currentSample.HasCSharpCode) { CSharpCodeRenderer.CSharpSource = await _currentSample.GetCSharpSourceAsync(); } if (_currentSample.HasJavaScriptCode) { JavaScriptCodeRenderer.JavaScriptSource = await _currentSample.GetJavaScriptSourceAsync(); } }
private async void InfoAreaPivot_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (InfoAreaPivot.SelectedItem != null) { if (DataContext is Sample sample) { TrackingManager.TrackEvent("PropertyGrid", (InfoAreaPivot.SelectedItem as FrameworkElement)?.Name, sample.Name); } } if (_currentSample == null) { return; } if (InfoAreaPivot.SelectedItem == PropertiesPivotItem) { // If we switch to the Properties Panel, we want to use a binded version of the Xaml Code. if (_currentSample.HasXAMLCode) { _lastRenderedProperties = true; var t = UpdateXamlRenderAsync(_currentSample.BindedXamlCode); } return; } if (_currentSample.HasXAMLCode && InfoAreaPivot.SelectedItem == XamlPivotItem && _lastRenderedProperties) { // Use this flag so we don't re-render the XAML tab if we're switching from tabs other than the properties one. _lastRenderedProperties = false; // If we switch to the Live Preview, then we want to use the Value based Text XamlCodeRenderer.Text = _currentSample.UpdatedXamlCode; var t = UpdateXamlRenderAsync(_currentSample.UpdatedXamlCode); await XamlCodeRenderer.RevealPositionAsync(new Position(1, 1)); return; } if (_currentSample.HasXAMLCode && InfoAreaPivot.SelectedItem == XamlReadOnlyPivotItem) { // Update Read-Only XAML tab on non-desktop devices to show changes to Properties XamlReadOnlyCodeRenderer.XamlSource = _currentSample.UpdatedXamlCode; } if (_currentSample.HasCSharpCode && InfoAreaPivot.SelectedItem == CSharpPivotItem) { CSharpCodeRenderer.CSharpSource = await _currentSample.GetCSharpSourceAsync(); return; } if (_currentSample.HasJavaScriptCode && InfoAreaPivot.SelectedItem == JavaScriptPivotItem) { JavaScriptCodeRenderer.JavaScriptSource = await _currentSample.GetJavaScriptSourceAsync(); return; } }
private async void NavigationFrame_Navigating(object sender, NavigatingCancelEventArgs navigationEventArgs) { if (navigationEventArgs.SourcePageType == typeof(SamplePicker) || navigationEventArgs.Parameter == null) { DataContext = null; if (navigationEventArgs.Parameter != null) { var category = navigationEventArgs.Parameter as SampleCategory; if (category != null) { TrackingManager.TrackPage($"{navigationEventArgs.SourcePageType.Name} - {category.Name}"); } } HideInfoArea(); } else { TrackingManager.TrackPage(navigationEventArgs.SourcePageType.Name); ShowInfoArea(); var sampleName = navigationEventArgs.Parameter.ToString(); var sample = await Samples.GetSampleByName(sampleName); if (sample == null) { HideInfoArea(); return; } var propertyDesc = sample.PropertyDescriptor; DataContext = sample; InfoAreaPivot.Items.Clear(); if (propertyDesc != null) { NavigationFrame.DataContext = propertyDesc.Expando; } Title.Text = sample.Name; _currentSample = sample; if (propertyDesc != null && propertyDesc.Options.Count > 0) { InfoAreaPivot.Items.Add(PropertiesPivotItem); } if (sample.HasXAMLCode) { XamlCodeRenderer.XamlSource = _currentSample.UpdatedXamlCode; InfoAreaPivot.Items.Add(XamlPivotItem); InfoAreaPivot.SelectedIndex = 0; } if (sample.HasCSharpCode) { CSharpCodeRenderer.CSharpSource = await _currentSample.GetCSharpSourceAsync(); InfoAreaPivot.Items.Add(CSharpPivotItem); } if (sample.HasJavaScriptCode) { JavaScriptCodeRenderer.CSharpSource = await _currentSample.GetJavaScriptSourceAsync(); InfoAreaPivot.Items.Add(JavaScriptPivotItem); } UpdateRootGridMinWidth(); if (!string.IsNullOrEmpty(sample.CodeUrl)) { GitHub.NavigateUri = new Uri(sample.CodeUrl); GitHub.Visibility = Visibility.Visible; } else { GitHub.Visibility = Visibility.Collapsed; } if (sample.HasDocumentation) { InfoAreaPivot.Items.Add(DocumentationPivotItem); DocumentationTextblock.Text = await _currentSample.GetDocumentationAsync(); } if (InfoAreaPivot.Items.Count == 0) { HideInfoArea(); } } }