private void UseHelperMethod() { var myHostControl = new WindowsXamlHost(); myHostControl.Dock = DockStyle.Fill; // Use helper method to create a UWP control instance. uwpButton = UWPTypeFactory.CreateXamlContentByType("Windows.UI.Xaml.Controls.Button") as Windows.UI.Xaml.Controls.Button; // Initialize UWP control. uwpButton.Name = "button1"; uwpButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; uwpButton.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; uwpButton.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Red); uwpButton.Click += delegate { uwpButton.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Blue); }; // initialize the Windows XAML host control. myHostControl.Name = "myWindowsXamlHostControl"; myHostControl.Child = uwpButton; // Make the UWP control appear in the UI. this.Controls.Add(myHostControl); }
public SemanticZoomPage() { this.InitializeComponent(); SemanticZoomPage.Current = this; // Links button this._links = new Dictionary <string, Uri>(); this._links["Doc: Touch Interaction Design"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/hh465415.aspx"); this._links["Doc: Guidelines for panning"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/hh465310.aspx"); this._links["API: Windows.UI.Input namespace"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/br212145.aspx"); this._links["API: GestureRecognizer class"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/br241937.aspx"); this._links["API: ManipulationStarted event"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.gesturerecognizer.manipulationstarted.aspx"); this._linksButton = GesturePageBase.CreateLinksAppBarButton(this._links); // Create the data source for the semantic zoom. // This is the actual content of this app: there is one item (page) for each gesture. this._pages = new List <IGesturePageInfo> { new WelcomePage().AppPageInfo, new AppEdgyPage().AppPageInfo, new SysEdgyPage().AppPageInfo, new TapPage().AppPageInfo, new PressAndHoldPage().AppPageInfo, new SwipePage().AppPageInfo, new ObjectZoomPage().AppPageInfo, new RotatePage().AppPageInfo, new SemanticZoomPage.GesturePage().AppPageInfo }; this.gesturesViewSource.Source = this._pages; }
public ObjectZoomPage() : base( "ObjectZoom", "Pinch and stretch to zoom", "Pinch or stretch two or more fingers on the screen to resize that object. If an object also supports panning, the user should be able to zoom and pan at the same time.", "Similar to when you use Ctrl+scrollwheel on a mouse.", "Assets/pinch.png") { this.InitializeComponent(); // Configure the app bar items for this page // GesturePageBase.Selected uses this._nonContextualItems to populate the global app bar when the page is selected. // Links button this._links["Doc: Guidelines for optical zoom and resizing"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/hh465307.aspx"); this._nonContextualItems.Add(GesturePageBase.CreateLinksAppBarButton(this._links)); // Reset button this._resetButton = new Windows.UI.Xaml.Controls.Button { Style = App.Current.Resources["ResetAppBarButtonStyle"] as Windows.UI.Xaml.Style }; this._resetButton.Click += (object sender, Windows.UI.Xaml.RoutedEventArgs e) => { this._manipulationManager.ResetManipulation(); }; }
/// <summary> /// Creates a button that when clicked displays a flyout with the specified <paramref name="links"/>. /// Clicking on a link opens a web browser on that page. /// </summary> /// <param name="links"></param> /// <returns></returns> internal static Windows.UI.Xaml.Controls.Button CreateLinksAppBarButton(Dictionary <string, Uri> links) { var popup = new Windows.UI.Popups.PopupMenu(); Windows.UI.Popups.UICommandInvokedHandler popupHandler = async(Windows.UI.Popups.IUICommand command) => { await Windows.System.Launcher.LaunchUriAsync(links[command.Label]); }; foreach (var item in links) { popup.Commands.Add(new Windows.UI.Popups.UICommand(item.Key, popupHandler)); } var button = new Windows.UI.Xaml.Controls.Button { Style = App.Current.Resources["LinksAppBarButtonStyle"] as Windows.UI.Xaml.Style }; button.Click += async(object sender, Windows.UI.Xaml.RoutedEventArgs e) => { var btnSender = sender as Windows.UI.Xaml.Controls.Button; var transform = btnSender.TransformToVisual(Windows.UI.Xaml.Window.Current.Content) as Windows.UI.Xaml.Media.MatrixTransform; var point = transform.TransformPoint(new Windows.Foundation.Point()); await popup.ShowAsync(point); }; return(button); }
public RotatePage() : base( "Rotate", "Turn to rotate", "Put two or more fingers on an object and turn your hand to rotate it. An object must be coded to support rotation for this to work.", "Similar to when you use Shift+Ctrl+scrollwheel on a mouse.", "Assets/rotate.png") { this.InitializeComponent(); // Configure the app bar items for this page // GesturePageBase.Selected uses this._nonContextualItems to populate the global app bar when the page is selected. // Links button this._links["Doc: Guidelines for rotation"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/hh465315.aspx"); this._links["API: Pivot center property"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.gesturerecognizer.pivotcenter.aspx"); this._links["API: Pivot radius property"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.gesturerecognizer.pivotradius.aspx"); this._nonContextualItems.Add(GesturePageBase.CreateLinksAppBarButton(this._links)); // Reset button this._resetButton = new Windows.UI.Xaml.Controls.Button { Style = App.Current.Resources["ResetAppBarButtonStyle"] as Windows.UI.Xaml.Style }; this._resetButton.Click += (object sender, Windows.UI.Xaml.RoutedEventArgs e) => { this._manipulationManager[this.leftImage].ResetManipulation(); this._manipulationManager[this.rightImage].ResetManipulation(); }; this._manipulationManager = new Dictionary <Windows.UI.Xaml.UIElement, Manipulations.ManipulationManager>(); }
private void WindowsXamlHost_XamlRootChanged(object sender, EventArgs e) { Windows.UI.Xaml.Controls.Button button = (Windows.UI.Xaml.Controls.Button)windowXamlHost.Child; if (button != null) { button.Content = "XAML Button"; button.Click += Button_Click; } }
private void WindowsXamlHost_ChildChanged(object sender, EventArgs e) { WindowsXamlHost windowsXamlHost = (WindowsXamlHost)sender; // 利用 Windows.UI.Xaml.Controls 做為轉換 Windows.UI.Xaml.Controls.Button button = (Windows.UI.Xaml.Controls.Button)windowsXamlHost.Child; Windows.UI.Xaml.Controls.TextBlock txt = new Windows.UI.Xaml.Controls.TextBlock(); txt.Text = "123"; button.Content = txt; }
protected override HandleRef BuildWindowCore(HandleRef hwndParent) { Win32Interop.EnableMouseInPointer(); // There are several different low-level interfaces available at this time. // Use XamlBridge unless you have a known reason to use the others. //IntPtr windowHandle = InitializePresenterHwndMode(hwndParent); //IntPtr windowHandle = InitializePresenterCoreWindowMode(hwndParent); IntPtr windowHandle = InitializeBridge(hwndParent); // Uncomment the following lines to create Xaml UI content directly from within this WPF host control. // Normally, the user of this control sets a property which is the name of a Xaml UserControl to instantiate. Windows.UI.Xaml.Controls.StackPanel panel = new Windows.UI.Xaml.Controls.StackPanel(); panel.Orientation = Windows.UI.Xaml.Controls.Orientation.Vertical; panel.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Red); Windows.UI.Xaml.Controls.TextBox textBox = new Windows.UI.Xaml.Controls.TextBox(); textBox.Text = "XAML TextBox 1"; panel.Children.Add(textBox); Windows.UI.Xaml.Controls.Button button = new Windows.UI.Xaml.Controls.Button(); button.Content = "XAML Button"; panel.Children.Add(button); textBox = new Windows.UI.Xaml.Controls.TextBox(); textBox.Text = "XAML TextBox 2"; panel.Children.Add(textBox); //XamlClassLibrary.TestUserControl testUserControl = new XamlClassLibrary.TestUserControl(); //panel.Children.Add(testUserControl); Windows.UI.Xaml.Window.Current.Content = panel; panel.LayoutUpdated += XamlContentLayoutUpdated; XamlApplication application = new XamlApplication(); String globalResourceFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "globalresources.xbf"); if (File.Exists(globalResourceFile)) { Windows.UI.Xaml.Application.LoadComponent(application, new Uri("ms-resource:///Files/globalresources.xaml")); } Windows.UI.Xaml.FrameworkElement contentRoot = panel; //var type = Type.GetType(ControlType, true, true); //Windows.UI.Xaml.FrameworkElement contentRoot = (Windows.UI.Xaml.FrameworkElement) Activator.CreateInstance("XamlClassLibrary", ControlType).Unwrap(); Windows.UI.Xaml.Window.Current.Content = contentRoot; contentRoot.LayoutUpdated += XamlContentLayoutUpdated; return(new HandleRef(this, windowHandle)); }
/// <summary> /// A Windows UI Button /// </summary> /// <returns>Button</returns> internal WUX.Controls.Control GetButton() { var button = new WUX.Controls.Button { HorizontalAlignment = WUX.HorizontalAlignment.Center, Margin = new WUX.Thickness(0, 10, 0, 0), Content = "UWP Button", }; return(button); }
private void OnChildChanged(object sender, EventArgs e) { if (uwpButton == null) { uwpButton = ((Microsoft.Toolkit.Wpf.UI.XamlHost.WindowsXamlHost)sender).Child as Windows.UI.Xaml.Controls.Button; uwpButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; uwpButton.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; uwpButton.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Red); uwpButton.Click += delegate { uwpButton.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Blue); }; } }
public SimpleButtonWindow() { InitializeComponent(); var button = new Windows.UI.Xaml.Controls.Button(); button.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; button.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; button.Content = "Say Something"; button.Click += Button_Click; XamlHost.Child = button; }
/// <summary> /// NumberClicked is called whenever a number is clicked on the UI calculator. /// Updates <see cref="DisplayText"/> to include the number that was clicked, and sets <see cref="OperationClicked"/> and /// <see cref="Calculated"/> to false. /// </summary> /// <param name="sender">The button that was pressed, such as 1, 2 , 3 etc.</param> /// <param name="e"></param> public void NumberClicked(object sender, RoutedEventArgs e) { if (DisplayText == "0" || (OperationClicked) || (Calculated)) { DisplayText = ""; } Windows.UI.Xaml.Controls.Button b = (Windows.UI.Xaml.Controls.Button)sender; DisplayText += b.Content; OperationClicked = false; Calculated = false; }
private void applyButon_ChildChanged(object sender, EventArgs e) { Windows.UI.Xaml.Controls.Button button = (sender as WindowsXamlHost).Child as Windows.UI.Xaml.Controls.Button; if (button != null) { button.Content = "应用"; button.CornerRadius = new Windows.UI.Xaml.CornerRadius(3); button.Click += (sender, e) => { App.Instance.WritePreference(Convert.ToSingle(titleBarThresholdLabel.Content), Convert.ToInt32(borderThresholdLabel.Content)); }; } }
private void OnButtonChanged(object sender, EventArgs e) { WindowsXamlHost wxh = (WindowsXamlHost)sender; Windows.UI.Xaml.Controls.Button btn = wxh.Child as Windows.UI.Xaml.Controls.Button; if (btn != null) { btn.Height = 100; btn.Width = 200; btn.Content = "Hello World"; btn.Click += OnClick; } }
private async void WebsiteButton_Click(object sender, RoutedEventArgs e) { await Task.Yield(); try { Windows.UI.Xaml.Controls.Button b = sender as Windows.UI.Xaml.Controls.Button; } catch (Exception ex) { AppLog.Instance.Error("Failed to load Rules PDF", ex); } }
private void exitButon_ChildChanged(object sender, EventArgs e) { Windows.UI.Xaml.Controls.Button button = (sender as WindowsXamlHost).Child as Windows.UI.Xaml.Controls.Button; if (button != null) { button.Content = "退出"; button.CornerRadius = new Windows.UI.Xaml.CornerRadius(3); button.Click += (sender, e) => { App.Current.Shutdown(); }; } }
/// <summary> /// Calculates the price of a cooler item by multiplying the display text by the retailer percentage of the button pressed /// </summary> /// <param name="sender">The Retailer button that was pressed, such as Walmart, Target, etc.</param> /// <param name="e"></param> public void CoolerWebsiteClick(object sender, RoutedEventArgs e) { IntermediateText = ""; if (DisplayText == "" || DisplayText == "0" || DisplayText == "." || DisplayText == null) { return; } OperationClicked = true; Windows.UI.Xaml.Controls.Button b = (Windows.UI.Xaml.Controls.Button)sender; int index = Int32.Parse(b.Name.Substring(6)) - 1; //All buttons named - Button1, Button2 - Corresponding to index Price = Double.Parse(DisplayText); DisplayText = RoundToNine(Price * (RetailButtonManager.RetailButtons[index].Retailer.CoolerPercentage / 100)).ToString(); }
public SimpleButtonForm() { InitializeComponent(); var myHostControl = new Microsoft.Toolkit.Forms.UI.XamlHost.WindowsXamlHost(); myHostControl.Dock = System.Windows.Forms.DockStyle.Fill; myHostControl.Name = "hostUwpButton"; var uwpButton = new Windows.UI.Xaml.Controls.Button(); uwpButton.Content = "Say Something!"; uwpButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; uwpButton.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; uwpButton.Click += UwpButton_Click; myHostControl.Child = uwpButton; this.Controls.Add(myHostControl); }
/// <summary> /// Logically represents the user pressing the decimal '.' button in the UI calculator /// </summary> /// <param name="sender">The '.' button in the UI calculator</param> /// <param name="e"></param> public void Decimal(object sender, RoutedEventArgs e) { if ((DisplayText == "0") || (OperationClicked) || (Calculated)) { DisplayText = ""; } if (HasDecimal == false) { Windows.UI.Xaml.Controls.Button b = (Windows.UI.Xaml.Controls.Button)sender; DisplayText += b.Content; OperationClicked = false; Calculated = false; HasDecimal = true; } else { return; } }
public SwipePage() : base( "Swipe", "Swipe to select", "Slide a short distance perpendicular to the scrolling direction to select an item. For example, if a page scrolls left and right, slide the object up or down. This selects the item and brings up the relevant app commands.", "Similar to when you use a mouse and right-click an item.", "Assets/swipe.png") { this.InitializeComponent(); // Configure the grid view that displays the tiles that can be swiped for selection this._items = new List <string>(); for (int i = 1; i < 11; i++) { this._items.Add("../Assets/swipe-" + i + ".png"); } this.itemsViewSource.Source = this._items; // Configure the app bar items for this page // GesturePageBase.Selected uses this._nonContextualItems to populate the global app bar when the page is selected. // Links button this._links["Doc: Guidelines for swipe to select/cross-slide"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/hh465299.aspx"); this._links["Doc: Guidelines for visual feedback"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/hh465342.aspx"); this._links["API: CrossSliding event"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.gesturerecognizer.crosssliding.aspx"); this._links["API: CrossSlidingEventArgs"] = new Uri("http://msdn.microsoft.com/en-US/library/windows/apps/windows.ui.input.crossslidingeventargs"); this._nonContextualItems.Add(GesturePageBase.CreateLinksAppBarButton(this._links)); // Store a reference to the globally shared AppBar. We will need it to automatically open the AppBar when something is selected in the grid view. this._appBar = (Windows.UI.Xaml.Controls.AppBar)GesturesApp.Pages.SemanticZoomPage.Current.FindName("globalAppBar"); // Clear selection button this._clearSelectionButton = new Windows.UI.Xaml.Controls.Button { Style = App.Current.Resources["ClearSelectionAppBarButtonStyle"] as Windows.UI.Xaml.Style }; this._clearSelectionButton.Click += (object sender, Windows.UI.Xaml.RoutedEventArgs e) => { this.tilesGridView.SelectedItems.Clear(); }; }
/* * This method takes an ElementChangedEventArgs parameter that contains OldElement and NewElement properties. * These properties represent the Xamarin.Forms element that the renderer was attached to, * and the Xamarin.Forms element that the renderer is attached to, respectively. * In the sample application the OldElement property will be null * and the NewElement property will contain a reference to the CameraPage instance. */ protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); Debug.Write(e.OldElement == null); Debug.Write(e.NewElement == null); if (e.OldElement != null || Element == null) { return; } Windows.UI.Xaml.Controls.Image image = new Windows.UI.Xaml.Controls.Image() { Width = 100, Height = 100, HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left }; BitmapImage bitmapImage = new BitmapImage(new Uri("ms-appx://XamarinCustomContentPage.UWP/Assets/picture.png")); image.Source = bitmapImage; sta = new Windows.UI.Xaml.Controls.StackPanel(); bt = new Windows.UI.Xaml.Controls.Button(); bt.Content = "hello , my custom page"; bt.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Color.FromArgb(25, 0, 0, 255)); bt.Click += OnClicked; sta.Children.Add(image); sta.Children.Add(bt); //instantiate a page page = new Windows.UI.Xaml.Controls.Page(); //add content to a page page.Content = sta; //put this page to this custom render as a children //must add content to the renderer,the content can be a stackpanel or the page or the image //a control only can be add into a contain control such as,if the image control add to the stackpanel , //it can not be added to page.content or this render.content this.Children.Add(page); }
private void WindowsXamlHost_ChildChanged(object sender, EventArgs e) { WindowsXamlHost windowsXamlHost = (WindowsXamlHost)sender; Windows.UI.Xaml.Controls.Button button = windowsXamlHost.Child as Windows.UI.Xaml.Controls.Button; if (button != null) { button.Content = "My UWP button"; button.Click += Button_Click; } UWP_Controls_Library.FunkyButton button2 = windowsXamlHost.Child as UWP_Controls_Library.FunkyButton; if (button2 != null) { button.Content = "My Funky button"; button.Click += Button_Click; } }
public void ClickButton(Windows.UI.Xaml.Controls.Button button) { throw new NotImplementedException(); }
// Create constructor public MainPage. public MainPage() { // Necessary to instantiate this Page, add a stackPanel to this Page, et cetera. this.InitializeComponent(); // Find width of app in view pixels and height between bottom of app and bottom of title bar in view pixels. double widthOfAppInViewPixels = Windows.UI.ViewManagement.ApplicationView.PreferredLaunchViewSize.Width; double heightBetweenBottomOfAppAndBottomOfTitleBarInViewPixels = Windows.UI.ViewManagement.ApplicationView.PreferredLaunchViewSize.Height; // Create a stackPanel. Windows.UI.Xaml.Controls.StackPanel stackPanel = new Windows.UI.Xaml.Controls.StackPanel(); // Create a toolbar with width equal to the width of the app, height equal to 50 view pixels, and background color of light blue that has one row and three columns. Windows.UI.Xaml.Controls.Grid toolbar = new Windows.UI.Xaml.Controls.Grid(); toolbar.Width = widthOfAppInViewPixels; toolbar.Height = 50; toolbar.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.AliceBlue); Windows.UI.Xaml.Controls.RowDefinition row = new Windows.UI.Xaml.Controls.RowDefinition(); toolbar.RowDefinitions.Add(row); Windows.UI.Xaml.Controls.ColumnDefinition columnForOpenImageButton = new Windows.UI.Xaml.Controls.ColumnDefinition(); Windows.UI.Xaml.Controls.ColumnDefinition columnForLoadBoundingBoxesButton = new Windows.UI.Xaml.Controls.ColumnDefinition(); Windows.UI.Xaml.Controls.ColumnDefinition columnForTextboxForClassIndex = new Windows.UI.Xaml.Controls.ColumnDefinition(); Windows.UI.Xaml.Controls.ColumnDefinition columnForSaveLabeledImageButton = new Windows.UI.Xaml.Controls.ColumnDefinition(); Windows.UI.Xaml.Controls.ColumnDefinition columnForSaveLabelFileButton = new Windows.UI.Xaml.Controls.ColumnDefinition(); columnForOpenImageButton.Width = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2); columnForLoadBoundingBoxesButton.Width = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2); columnForTextboxForClassIndex.Width = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels / 7); columnForSaveLabeledImageButton.Width = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2); columnForSaveLabelFileButton.Width = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2); toolbar.ColumnDefinitions.Add(columnForOpenImageButton); toolbar.ColumnDefinitions.Add(columnForLoadBoundingBoxesButton); toolbar.ColumnDefinitions.Add(columnForTextboxForClassIndex); toolbar.ColumnDefinitions.Add(columnForSaveLabeledImageButton); toolbar.ColumnDefinitions.Add(columnForSaveLabelFileButton); // Add to toolbar's columnForOpenImageButton an "Open Image" button. Windows.UI.Xaml.Controls.Button openImageButton = new Windows.UI.Xaml.Controls.Button(); openImageButton.Content = "Open Image"; openImageButton.Height = 40; Windows.UI.Xaml.Controls.Grid.SetRow(openImageButton, 0); Windows.UI.Xaml.Controls.Grid.SetColumn(openImageButton, 0); openImageButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; openImageButton.Click += OpenImageButton_Click; toolbar.Children.Add(openImageButton); // Add to the toolbar's columnForLoadBoundingBoxesButton a "Load Bounding Boxes" button. Windows.UI.Xaml.Controls.Button loadBoundingBoxesButton = new Windows.UI.Xaml.Controls.Button(); loadBoundingBoxesButton.Content = "Load Bounding Boxes"; loadBoundingBoxesButton.Height = 40; Windows.UI.Xaml.Controls.Grid.SetRow(loadBoundingBoxesButton, 0); Windows.UI.Xaml.Controls.Grid.SetColumn(loadBoundingBoxesButton, 1); loadBoundingBoxesButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; loadBoundingBoxesButton.Click += LoadBoundingBoxesButton_Click; toolbar.Children.Add(loadBoundingBoxesButton); // Add to toolbar's columnForTextboxForClassIndex a labeled text box to store a user's choice of class index for an object they are about to bound. Windows.UI.Xaml.Controls.TextBlock textblockForClassIndex = new Windows.UI.Xaml.Controls.TextBlock(); textblockForClassIndex.Text = "Class Index: "; textblockForClassIndex.Height = 20; Windows.UI.Xaml.Controls.Grid.SetRow(textblockForClassIndex, 0); Windows.UI.Xaml.Controls.Grid.SetColumn(textblockForClassIndex, 2); toolbar.Children.Add(textblockForClassIndex); this.TextBoxForClassIndex = new Windows.UI.Xaml.Controls.TextBox(); this.TextBoxForClassIndex.Text = "0"; this.TextBoxForClassIndex.Width = 40; this.TextBoxForClassIndex.Height = 40; Windows.UI.Xaml.Controls.Grid.SetRow(this.TextBoxForClassIndex, 0); Windows.UI.Xaml.Controls.Grid.SetColumn(this.TextBoxForClassIndex, 2); this.TextBoxForClassIndex.TextChanged += TextBoxForClassIndex_TextChanged; toolbar.Children.Add(this.TextBoxForClassIndex); // Add to toolbar's columnForSaveLabeledImageButton a "Save Labeled Image" button. Windows.UI.Xaml.Controls.Button saveLabeledImageButton = new Windows.UI.Xaml.Controls.Button(); saveLabeledImageButton.Content = "Save Labeled Image"; saveLabeledImageButton.Height = 40; Windows.UI.Xaml.Controls.Grid.SetRow(saveLabeledImageButton, 0); Windows.UI.Xaml.Controls.Grid.SetColumn(saveLabeledImageButton, 3); saveLabeledImageButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; saveLabeledImageButton.Click += SaveLabeledImageButton_Click; toolbar.Children.Add(saveLabeledImageButton); // Add to toolbar's columnForSaveLabelFileButton a "Save Label File" button. Windows.UI.Xaml.Controls.Button saveLabelFileButton = new Windows.UI.Xaml.Controls.Button(); saveLabelFileButton.Content = "Save Label File"; saveLabelFileButton.Height = 40; Windows.UI.Xaml.Controls.Grid.SetRow(saveLabelFileButton, 0); Windows.UI.Xaml.Controls.Grid.SetColumn(saveLabelFileButton, 4); saveLabelFileButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; saveLabelFileButton.Click += SaveLabelFileButton_Click; toolbar.Children.Add(saveLabelFileButton); // Add grid to the top of our stackPanel. stackPanel.Children.Add(toolbar); this.ImageCanvas = new Windows.UI.Xaml.Controls.Canvas(); this.ImageCanvas.Width = widthOfAppInViewPixels; this.ImageCanvas.Height = heightBetweenBottomOfAppAndBottomOfTitleBarInViewPixels - toolbar.Height; this.ImageCanvas.PointerMoved += new Windows.UI.Xaml.Input.PointerEventHandler(ImageCanvas_PointerMoved); this.ImageCanvas.PointerPressed += new Windows.UI.Xaml.Input.PointerEventHandler(ImageCanvas_PointerPressed); this.ImageCanvas.PointerExited += new Windows.UI.Xaml.Input.PointerEventHandler(ImageCanvas_PointerExited); stackPanel.Children.Add(this.ImageCanvas); // Add stackPanel to the page defined in MainPage.xaml. page.Content = stackPanel; } // public MainPage
private void WindowsXamlHost_Loaded(object sender, RoutedEventArgs e) { windows.UI.Xaml.Controls.StackPanel stackPanel = new windows.UI.Xaml.Controls.StackPanel() { Background = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Black), }; stackPanel.Children.Add(new windows.UI.Xaml.Shapes.Rectangle() { Width = 50, Height = 75, Fill = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Blue), }); stackPanel.Children.Add(new windows.UI.Xaml.Shapes.Rectangle() { Width = 200, Height = 30, Fill = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Red), }); var button = new windows.UI.Xaml.Controls.Button() { Width = 160, Height = 60, HorizontalAlignment = windows.UI.Xaml.HorizontalAlignment.Center, Content = "ContentDialog UWP Button", }; button.Tapped += Button_Tapped; stackPanel.Children.Add(button); stackPanel.Children.Add(new windows.UI.Xaml.Shapes.Rectangle() { Width = 25, Height = 100, Fill = new windows.UI.Xaml.Media.SolidColorBrush(windows.UI.Colors.Green), }); windows.UI.Xaml.Controls.Flyout flyout = new windows.UI.Xaml.Controls.Flyout(); flyout.Content = new windows.UI.Xaml.Controls.TextBlock() { Text = "Flyout content", }; var button2 = new windows.UI.Xaml.Controls.Button() { Width = 300, Height = 40, HorizontalAlignment = windows.UI.Xaml.HorizontalAlignment.Center, Content = "Long UWP Button with Flyout", Flyout = flyout, }; stackPanel.Children.Add(button2); var comboBox = new windows.UI.Xaml.Controls.ComboBox() { HorizontalAlignment = windows.UI.Xaml.HorizontalAlignment.Center, }; comboBox.Items.Add("One"); comboBox.Items.Add("Two"); comboBox.Items.Add("Three"); comboBox.Items.Add("Four"); stackPanel.Children.Add(comboBox); windows.UI.Xaml.Controls.Grid grid = new windows.UI.Xaml.Controls.Grid(); stackPanel.Children.Add(grid); _contentDialog = new windows.UI.Xaml.Controls.ContentDialog(); _contentDialog.Content = new windows.UI.Xaml.Controls.TextBlock() { Text = "ContentDialog content", }; stackPanel.Children.Add(_contentDialog); var popup = new windows.UI.Xaml.Controls.Primitives.Popup() { Width = 50, Height = 50, ShouldConstrainToRootBounds = false, Child = new windows.UI.Xaml.Controls.TextBlock() { Text = "Popup child", }, }; grid.Children.Add(popup); windowsXamlHost.Child = stackPanel; popup.IsOpen = true; }