protected Slider CreateSlider(PropertyInfo propertyInfo, MethodInfo autoCall, float startValue, SliderCommand.Range range, Action<float> onValueChanged) { var slider = new Slider { Minimum = range.Minimum, Maximum = range.Maximum, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Value = startValue }; slider.PropertyChanged += SliderOnPropertyChanged(propertyInfo, onValueChanged, autoCall); return slider; }
public OptionsWindow() { Title = "Options (Switch tabs with LB and RB)"; CanResize = false; CanDrag = false; HorizontalAlignment = HorizontalAlignment.Center; VerticalAlignment = VerticalAlignment.Center; var nameTextBlock = new TextBlock { Margin = new Vector4F(4), Text = "Your name:", }; var nameTextBox = new TextBox { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, Text = "Player1", }; var passwordTextBlock = new TextBlock { Margin = new Vector4F(4), Text = "Your password:"******"Difficulty:", }; var easyRadioButton = new RadioButton { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, Content = new TextBlock { Text = "Easy" }, GroupName = "Difficulty", }; var normalRadioButton = new RadioButton { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, Content = new TextBlock { Text = "Normal" }, GroupName = "Difficulty", IsChecked = true, }; var hardRadioButton = new RadioButton { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, Content = new TextBlock { Text = "Hard" }, GroupName = "Difficulty", }; var modeTextBlock = new TextBlock { Margin = new Vector4F(4), Text = "Mode:", }; var simulationRadioButton = new RadioButton { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, Content = new TextBlock { Text = "Simulation" }, GroupName = "Mode", }; var arcadeRadioButton = new RadioButton { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, Content = new TextBlock { Text = "Arcade" }, GroupName = "Mode", IsChecked = true, }; var generalPanel = new StackPanel { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, }; generalPanel.Children.Add(nameTextBlock); generalPanel.Children.Add(nameTextBox); generalPanel.Children.Add(passwordTextBlock); generalPanel.Children.Add(passwordTextBox); generalPanel.Children.Add(difficultyTextBlock); generalPanel.Children.Add(easyRadioButton); generalPanel.Children.Add(normalRadioButton); generalPanel.Children.Add(hardRadioButton); generalPanel.Children.Add(modeTextBlock); generalPanel.Children.Add(simulationRadioButton); generalPanel.Children.Add(arcadeRadioButton); var generalTab = new TabItem { TabPage = generalPanel, Content = new TextBlock { Text = "General" }, }; var resolutionTextBlock = new TextBlock { Margin = new Vector4F(4), Text = "Resolution:", }; var resolutionDropDownButton = new DropDownButton { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, MaxDropDownHeight = 400, }; resolutionDropDownButton.Items.Add("640 x 400"); resolutionDropDownButton.Items.Add("800 x 480"); resolutionDropDownButton.Items.Add("1024 x 768"); resolutionDropDownButton.Items.Add("1280 x 720"); resolutionDropDownButton.Items.Add("1920 x 1080"); resolutionDropDownButton.Items.Add("1920 x 1200"); resolutionDropDownButton.SelectedIndex = 3; var qualityTextBlock = new TextBlock { Margin = new Vector4F(4), Text = "Quality:", }; var qualityValueTextBlock = new TextBlock { Margin = new Vector4F(4), }; var qualityTextPanel = new StackPanel { Orientation = Orientation.Horizontal, }; qualityTextPanel.Children.Add(qualityTextBlock); qualityTextPanel.Children.Add(qualityValueTextBlock); var qualitySlider = new Slider { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, Minimum = 0, Maximum = 10, SmallChange = 1, // This value is used when the user presses LEFT/RIGHT to move the slider. LargeChange = 1, // This value is used when the user presses the slider (not the thumb). }; // Each game object property (e.g. Slider.Minimum/Maximum/Margin/Value/...) has a Changing // and a Changed event. To use it, we have to get the property: GameProperty<float> sliderValueProperty = qualitySlider.Properties.Get<float>("Value"); // We can use the Changing event to coerce the property value. For example: A normal slider // can have any values when dragged with the mouse. We can coerce the value to only allow // integer values! sliderValueProperty.Changing += (s, e) => e.CoercedValue = (float)Math.Round(e.CoercedValue); // We can use the Changed event to update dependent values. Here, we update the text block // text whenever the slider value changes. sliderValueProperty.Changed += (s, e) => qualityValueTextBlock.Text = qualitySlider.Value.ToString(); // Initialize the slider value. This raises the Changing and Changed events, and the // qualityValueTextBlock is updated too. qualitySlider.Value = 4; var graphicsPanel = new StackPanel { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, }; graphicsPanel.Children.Add(resolutionTextBlock); graphicsPanel.Children.Add(resolutionDropDownButton); graphicsPanel.Children.Add(qualityTextPanel); graphicsPanel.Children.Add(qualitySlider); var graphicsTab = new TabItem { TabPage = graphicsPanel, Content = new TextBlock { Text = "Graphics" }, }; var tabControl = new TabControl { Width = 300, Height = 300, Margin = new Vector4F(4) }; tabControl.Items.Add(generalTab); tabControl.Items.Add(graphicsTab); var okButton = new Button { Width = 100, Margin = new Vector4F(4), Content = new TextBlock { Text = "OK (START)" }, IsDefault = true, }; okButton.Click += OnOK; var cancelButton = new Button { Width = 100, Margin = new Vector4F(4), Content = new TextBlock { Text = "Cancel (BACK)" }, IsCancel = true, }; cancelButton.Click += OnCancel; var buttonPanel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, }; buttonPanel.Children.Add(okButton); buttonPanel.Children.Add(cancelButton); var mainPanel = new StackPanel { Margin = new Vector4F(4) }; mainPanel.Children.Add(tabControl); mainPanel.Children.Add(buttonPanel); Content = mainPanel; }
protected override void OnLoad() { base.OnLoad(); var screen = Screen; var panel = new Canvas { Margin = new Vector4F(8), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; Content = panel; panel.Children.Add(new TextBlock { Text = "The GUI can be used in the 3D game! :-)", }); panel.Children.Add(new TextBlock { Y = 32, Text = "Red: ", }); var slider = new Slider { X = 52, Y = 32, Width = 200, Minimum = 0, Maximum = 255, Value = screen.Background.R, }; panel.Children.Add(slider); GameProperty<float> sliderValue = slider.Properties.Get<float>("Value"); sliderValue.Changed += (s, e) => { Color color = screen.Background; color.R = (byte)e.NewValue; screen.Background = color; }; panel.Children.Add(new TextBlock { X = 0, Y = 56, Text = "Green: ", }); slider = new Slider { X = 52, Y = 56, Width = 200, Minimum = 0, Maximum = 255, Value = screen.Background.G, }; panel.Children.Add(slider); sliderValue = slider.Properties.Get<float>("Value"); sliderValue.Changed += (s, e) => { Color color = screen.Background; color.G = (byte)e.NewValue; screen.Background = color; }; panel.Children.Add(new TextBlock { X = 0, Y = 80, Text = "Blue: ", }); slider = new Slider { X = 52, Y = 80, Width = 200, Minimum = 0, Maximum = 255, Value = screen.Background.B, }; panel.Children.Add(slider); sliderValue = slider.Properties.Get<float>("Value"); sliderValue.Changed += (s, e) => { Color color = screen.Background; color.B = (byte)e.NewValue; screen.Background = color; }; var button = new Button { X = 60, Y = 110, Width = 120, ToolTip = "Drop a new box", Content = new TextBlock { Text = "Drop" }, }; button.Click += (s, e) => { // Create a new DynamicObject. var gameObjectService = _services.GetInstance<IGameObjectService>(); gameObjectService.Objects.Add(new DynamicObject(_services, 1)); }; panel.Children.Add(button); }
public AllControlsWindow(ContentManager content, IUIRenderer renderer) { Title = "All Controls (This window has a context menu!)"; CanResize = false; // The window content is set to a horizontal stack panel that contains two vertical // stack panels. The controls are added to the vertical panels. // ----- Button with text content var button0 = new Button { Content = new TextBlock { Text = "Button" }, Margin = new Vector4F(4), }; // ----- Button with mixed content // The content of a button is usually a text block but can be any UI control. // Let's try a button with image + text. var buttonContentPanel = new StackPanel { Orientation = Orientation.Horizontal }; buttonContentPanel.Children.Add(new Image { Width = 16, Height = 16, Texture = content.Load<Texture2D>("Icon") }); buttonContentPanel.Children.Add(new TextBlock { Margin = new Vector4F(4, 0, 0, 0), Text = "Button with image", VerticalAlignment = VerticalAlignment.Center, }); var button1 = new Button { Content = buttonContentPanel, Margin = new Vector4F(4), }; // ----- Drop-down button var dropDown = new DropDownButton { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(4), MaxDropDownHeight = 250, }; for (int i = 0; i < 20; i++) { dropDown.Items.Add("DropDownItem " + i); } dropDown.SelectedIndex = 0; // ----- Check box var checkBox = new CheckBox { Margin = new Vector4F(4), Content = new TextBlock { Text = "CheckBox" }, }; // ----- Group of radio buttons var radioButton0 = new RadioButton { Margin = new Vector4F(4, 8, 4, 4), Content = new TextBlock { Text = "RadioButton0" }, }; var radioButton1 = new RadioButton { Margin = new Vector4F(4, 2, 4, 2), Content = new TextBlock { Text = "RadioButton1" }, }; var radioButton2 = new RadioButton { Margin = new Vector4F(4, 2, 4, 4), Content = new TextBlock { Text = "RadioButton1" }, }; // ----- Progress bar with value var progressBar0 = new ProgressBar { IsIndeterminate = false, Value = 75, Margin = new Vector4F(4, 8, 4, 4), HorizontalAlignment = HorizontalAlignment.Stretch, Cursor = renderer.GetCursor("Wait"), }; // ----- Progress bar without value (indeterminate) var progressBar1 = new ProgressBar { IsIndeterminate = true, Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, Cursor = renderer.GetCursor("Wait"), }; // ----- Slider connected with a text box. var slider = new Slider { Value = 60, Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, }; var sliderValue = new TextBlock { Margin = new Vector4F(4, 0, 4, 4), Text = "(Value = 60)", HorizontalAlignment = HorizontalAlignment.Right }; // To connect the slider with the text box, we need to get the "Value" property. var valueProperty = slider.Properties.Get<float>("Value"); // This property is a GameObjectProperty<float>. We can attach an event handler to // the Changed event of the property. valueProperty.Changed += (s, e) => sliderValue.Text = "(Value = " + (int)e.NewValue + ")"; // ----- Scroll bar var scrollBar = new ScrollBar { Style = "ScrollBarHorizontal", SmallChange = 1, LargeChange = 10, Value = 45, ViewportSize = 0.3f, Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, }; // Add the controls to the first vertical stack panel. var stackPanel0 = new StackPanel { Margin = new Vector4F(4), }; stackPanel0.Children.Add(button0); stackPanel0.Children.Add(button1); stackPanel0.Children.Add(dropDown); stackPanel0.Children.Add(checkBox); stackPanel0.Children.Add(radioButton0); stackPanel0.Children.Add(radioButton1); stackPanel0.Children.Add(radioButton2); stackPanel0.Children.Add(progressBar0); stackPanel0.Children.Add(progressBar1); stackPanel0.Children.Add(slider); stackPanel0.Children.Add(sliderValue); stackPanel0.Children.Add(scrollBar); // ----- Group box var groupBox = new GroupBox { Title = "GroupBox", HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(4), Content = new TextBlock { Margin = new Vector4F(4), Text = "GroupBox Content" } }; // ----- Tab control with 3 tab items var tabItem0 = new TabItem { TabPage = new TextBlock { Margin = new Vector4F(4), Text = "Page 0" }, Content = new TextBlock { Text = "Item 0" }, }; var tabItem1 = new TabItem { TabPage = new TextBlock { Margin = new Vector4F(4), Text = "Page 1" }, Content = new TextBlock { Text = "Item 1" }, }; var tabItem2 = new TabItem { TabPage = new TextBlock { Margin = new Vector4F(4), Text = "Page 2" }, Content = new TextBlock { Text = "Item 2" }, }; var tabControl = new TabControl { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(4), }; tabControl.Items.Add(tabItem0); tabControl.Items.Add(tabItem1); tabControl.Items.Add(tabItem2); // ----- Scroll viewer showing an image var image = new Image { Texture = content.Load<Texture2D>("Sky"), }; var scrollViewer = new ScrollViewer { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, MinHeight = 100, HorizontalOffset = 200, VerticalOffset = 200, Height = 200, }; scrollViewer.Content = image; // ----- Text box var textBox0 = new TextBox { Margin = new Vector4F(4), Text = "The quick brown fox jumps over the lazy dog.", MaxLines = 1, HorizontalAlignment = HorizontalAlignment.Stretch, }; // ----- Password box var textBox1 = new TextBox { Margin = new Vector4F(4), Text = "Secret password!", MaxLines = 1, IsPassword = true, HorizontalAlignment = HorizontalAlignment.Stretch, }; // ----- Multi-line text box var textBox2 = new TextBox { Margin = new Vector4F(4), Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifend, nulla semper vestibulum congue, lectus lectus aliquam magna, lobortis luctus sem magna sit amet elit. Integer at neque nec mi dapibus tincidunt. Maecenas elit quam, varius luctus rutrum ut, congue quis libero. In hac habitasse platea dictumst. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus eu ante eros. Etiam odio lectus, sagittis non dictum eu, faucibus vitae magna. Maecenas mi lorem, semper vel condimentum sit amet, vehicula quis nulla. Cras suscipit scelerisque orci, ac ullamcorper lorem egestas sed. Nulla facilisi. Nam justo enim, mollis nec condimentum non, consectetur vel purus. Curabitur ac diam vitae justo ultricies auctor.\n" + "Pellentesque interdum vehicula nisi sed congue. Etiam eget magna nec metus suscipit tincidunt et in lectus. Praesent sapien tortor, congue et semper eu, mattis ac lorem. Duis id est et justo tempus consectetur. Aliquam rutrum ullamcorper augue non varius. Fusce ornare lectus et ipsum lobortis ut venenatis tellus sodales. Proin venenatis scelerisque dui eu viverra. Pellentesque vitae risus eget tellus vehicula molestie et quis ante. Nulla imperdiet rhoncus ante, eu tristique ante euismod id. Sed varius varius hendrerit. Praesent massa tortor, gravida suscipit lacinia non, suscipit a ipsum. Integer vulputate, felis vitae consectetur bibendum, ante velit tincidunt nunc, in convallis erat dolor eu purus.", MinLines = 5, MaxLines = 5, HorizontalAlignment = HorizontalAlignment.Stretch, }; // ----- Console (command prompt) var console = new Console { Margin = new Vector4F(4), HorizontalAlignment = HorizontalAlignment.Stretch, MinHeight = 100, }; // Add the controls to the second vertical stack panel. var stackPanel1 = new StackPanel { Width = 250, Margin = new Vector4F(4), }; stackPanel1.Children.Add(groupBox); stackPanel1.Children.Add(tabControl); stackPanel1.Children.Add(scrollViewer); stackPanel1.Children.Add(textBox0); stackPanel1.Children.Add(textBox1); stackPanel1.Children.Add(textBox2); stackPanel1.Children.Add(console); // Add the two vertical stack panel into a horizontal stack panel. var stackPanelHorizontal = new StackPanel { Orientation = Orientation.Horizontal }; stackPanelHorizontal.Children.Add(stackPanel0); stackPanelHorizontal.Children.Add(stackPanel1); Content = stackPanelHorizontal; // ----- Add a context menu to the window. (Each UI control can have its own context menu.) ContextMenu = new ContextMenu(); // Add menu items. for (int i = 0; i < 10; i++) { var menuItem = new MenuItem { Content = new TextBlock { Text = "MenuItem" + i }, }; ContextMenu.Items.Add(menuItem); } }
public EasingWindow(IServiceLocator services) : base(services) { _inputService = services.GetInstance<IInputService>(); _animationService = services.GetInstance<IAnimationService>(); Title = "EasingWindow"; StackPanel stackPanel = new StackPanel { Margin = new Vector4F(8) }; Content = stackPanel; TextBlock textBlock = new TextBlock { Text = "Test different Easing Functions in this window.", Margin = new Vector4F(0, 0, 0, 8), }; stackPanel.Children.Add(textBlock); StackPanel horizontalPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Vector4F(0, 0, 0, 8) }; stackPanel.Children.Add(horizontalPanel); textBlock = new TextBlock { Text = "Easing Function:", Width = 80, Margin = new Vector4F(0, 0, 8, 0), }; horizontalPanel.Children.Add(textBlock); _functionDropDown = new DropDownButton { Width = 100, // The DropDownButton automatically converts the items to string (using ToString) and // displays this string. This is not helpful for this sort of items. We want to display // the type name of the items instead. The following is a callback which creates a // TextBlock for each item. It is called when the drop-down list is opened. CreateControlForItem = item => new TextBlock { Text = item.GetType().Name }, }; horizontalPanel.Children.Add(_functionDropDown); _functionDropDown.Items.Add(new BackEase()); _functionDropDown.Items.Add(new BounceEase()); _functionDropDown.Items.Add(new CircleEase()); _functionDropDown.Items.Add(new CubicEase()); _functionDropDown.Items.Add(new ElasticEase()); _functionDropDown.Items.Add(new ExponentialEase()); _functionDropDown.Items.Add(new LogarithmicEase()); _functionDropDown.Items.Add(new HermiteEase()); _functionDropDown.Items.Add(new PowerEase()); _functionDropDown.Items.Add(new QuadraticEase()); _functionDropDown.Items.Add(new QuinticEase()); _functionDropDown.Items.Add(new SineEase()); _functionDropDown.SelectedIndex = 0; horizontalPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Vector4F(0, 0, 0, 8) }; stackPanel.Children.Add(horizontalPanel); textBlock = new TextBlock { Text = "Easing Mode:", Width = 80, Margin = new Vector4F(0, 0, 8, 0), }; horizontalPanel.Children.Add(textBlock); _modeDropDown = new DropDownButton { Width = 100, }; horizontalPanel.Children.Add(_modeDropDown); _modeDropDown.Items.Add(EasingMode.EaseIn); _modeDropDown.Items.Add(EasingMode.EaseOut); _modeDropDown.Items.Add(EasingMode.EaseInOut); _modeDropDown.SelectedIndex = 0; _slider = new Slider { Margin = new Vector4F(0, 16, 0, 0), SmallChange = 0.01f, LargeChange = 0.1f, Minimum = -0.5f, Maximum = 1.5f, Width = 250, HorizontalAlignment = HorizontalAlignment.Center, }; stackPanel.Children.Add(_slider); // Display the current value of the slider. var valueLabel = new TextBlock { Text = _slider.Value.ToString("F2"), HorizontalAlignment = HorizontalAlignment.Center, Margin = new Vector4F(0, 0, 0, 8), }; stackPanel.Children.Add(valueLabel); // Update the text every time the slider value changes. var valueProperty = _slider.Properties.Get<float>("Value"); valueProperty.Changed += (s, e) => valueLabel.Text = e.NewValue.ToString("F2"); Button button = new Button { Content = new TextBlock { Text = "Animate" }, HorizontalAlignment = HorizontalAlignment.Center, Margin = new Vector4F(0, 0, 0, 8), }; button.Click += OnButtonClicked; stackPanel.Children.Add(button); textBlock = new TextBlock { Text = "(Press the Animate button to animate the slider\n" + "value using the selected EasingFunction.\n" + "The slider goes from -0.5 to 1.5. The animation\n" + "animates the value to 0 or to 1.)", }; stackPanel.Children.Add(textBlock); // When the window is loaded, the window appears under the mouse cursor and flies to // its position. Vector2F mousePosition = _inputService.MousePosition; // The loading animation is a timeline group of three animations: // - One animations animates the RenderScale from (0, 0) to its current value. // - The other animations animate the X and Y positions from the mouse position // to current values. // The base class AnimatedWindow will apply this timeline group on this window // when the window is loaded. TimelineGroup timelineGroup = new TimelineGroup { new Vector2FFromToByAnimation { TargetProperty = "RenderScale", From = new Vector2F(0, 0), Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new HermiteEase { Mode = EasingMode.EaseOut }, }, new SingleFromToByAnimation { TargetProperty = "X", From = mousePosition.X, Duration = TimeSpan.FromSeconds(0.3), }, new SingleFromToByAnimation { TargetProperty = "Y", From = mousePosition.Y, Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new QuadraticEase { Mode = EasingMode.EaseIn }, }, }; // The default FillBehavior is "Hold". But this animation can be removed when it is finished. // It should not "Hold" the animation value. If FillBehavior is set to Hold, we cannot // drag the window with the mouse because the animation overrides the value. timelineGroup.FillBehavior = FillBehavior.Stop; LoadingAnimation = timelineGroup; // The closing animation is a timeline group of three animations: // - One animations animates the RenderScale to (0, 0). // - The other animations animate the X and Y positions to the mouse position. // The base class AnimatedWindow will apply this timeline group on this window // when the window is loaded. ClosingAnimation = new TimelineGroup { new Vector2FFromToByAnimation { TargetProperty = "RenderScale", To = new Vector2F(0, 0), Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new HermiteEase { Mode = EasingMode.EaseIn }, }, new SingleFromToByAnimation { TargetProperty = "X", To = mousePosition.X, Duration = TimeSpan.FromSeconds(0.3), }, new SingleFromToByAnimation { TargetProperty = "Y", To = mousePosition.Y, Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new QuadraticEase { Mode = EasingMode.EaseOut }, }, }; }
// Create a window which shows all controls. public WpWindow() { CanDrag = false; CanResize = false; HorizontalAlignment = HorizontalAlignment.Stretch; VerticalAlignment = VerticalAlignment.Stretch; Title = "DigitalRune Game UI Sample"; // We handle the Closed event. Closed += OnClosed; var applicationTitle = new TextBlock { Text = "DIGITALRUNE GUI SAMPLE", Margin = new Vector4F(12, 0, 0, 0), }; var pageTitle = new TextBlock { Text = "controls", Style = "TextBlockTitle", Margin = new Vector4F(9, -7, 0, 0), }; var titlePanel = new StackPanel { Margin = new Vector4F(12, 24, 8, 8), }; titlePanel.Children.Add(applicationTitle); titlePanel.Children.Add(pageTitle); var textBlock = new TextBlock { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(0, 10, 0, 10), WrapText = true, Text = "This is a window with a lot of controls.\n" + "All controls are within a scroll viewer.\n" + "Tap-and-hold in window area to display the context menu of the window.", Style = "TextBlockSubtle" }; var buttonEnabled = new Button { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "Button" }, }; var buttonDisabled = new Button { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "Button (Disabled)" }, IsEnabled = false, }; var checkBoxEnabled = new CheckBox { Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "CheckBox" }, }; var checkBoxEnabledChecked = new CheckBox { Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "CheckBox" }, IsChecked = true, }; var checkBoxDisabled = new CheckBox { Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "CheckBox (Disabled)" }, IsEnabled = false, }; var checkBoxDisabledChecked = new CheckBox { Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "CheckBox (Disabled)" }, IsEnabled = false, IsChecked = true, }; var checkBoxLotsOfText = new CheckBox { Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "CheckBox with a lot of text that does not fit into a single line." }, }; var radioButton0 = new RadioButton { Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "RadioButton" }, }; var radioButton1 = new RadioButton { Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "RadioButton with a lot of text that does not fit into a single line." }, IsChecked = true }; var radioButton2 = new RadioButton { Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "RadioButton" }, IsEnabled = false, }; var radioButton3 = new RadioButton { Margin = new Vector4F(0, 10, 0, 10), Content = new TextBlock { Text = "RadioButton (Disabled)" }, IsEnabled = false, IsChecked = true, GroupName = "OtherGroup", // Put in another group, so that the IsChecked state is not removed when the user clicks another radio button. }; var dropDownButton = new DropDownButton { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(0, 10, 0, 10), Title = "DROPDOWN ITEMS", SelectedIndex = 0, }; // Add drop down items - each items is a string. Per default, the DropDownButton // calls ToString() for each item and displays it in a text block. for (int i = 0; i < 30; i++) dropDownButton.Items.Add("DropDownItem " + i); var dropDownButtonDisabled = new DropDownButton { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(0, 10, 0, 10), Title = "DROPDOWN ITEMS", IsEnabled = false, SelectedIndex = 0, }; // Add drop down items - each items is a string. Per default, the DropDownButton // calls ToString() for each item and displays it in a text block. for (int i = 0; i < 30; i++) dropDownButtonDisabled.Items.Add("DropDownItem " + i + "(Disabled)"); var textBoxEnabled = new TextBox { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(0, 10, 0, 10), GuideTitle = "GUIDE TITLE", GuideDescription = "Guide description:", Text = "TextBox (Enabled)" }; var textBoxDisabled = new TextBox { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(0, 10, 0, 10), Text = "TextBox (Disabled)", IsEnabled = false, }; var slider = new Slider { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(0, 24, 0, 24), Value = 33 }; var progressBar = new ProgressBar { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(0, 10, 0, 10), Value = 66, }; var progressBarIndeterminate = new ProgressBar { HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Vector4F(0, 10, 0, 10), IsIndeterminate = true, }; var stackPanel = new StackPanel { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Margin = new Vector4F(0, 0, 8, 0), }; stackPanel.Children.Add(textBlock); stackPanel.Children.Add(buttonEnabled); stackPanel.Children.Add(buttonDisabled); stackPanel.Children.Add(checkBoxEnabled); stackPanel.Children.Add(checkBoxEnabledChecked); stackPanel.Children.Add(checkBoxDisabled); stackPanel.Children.Add(checkBoxDisabledChecked); stackPanel.Children.Add(checkBoxLotsOfText); stackPanel.Children.Add(radioButton0); stackPanel.Children.Add(radioButton1); stackPanel.Children.Add(radioButton2); stackPanel.Children.Add(radioButton3); stackPanel.Children.Add(dropDownButton); stackPanel.Children.Add(dropDownButtonDisabled); stackPanel.Children.Add(textBoxEnabled); stackPanel.Children.Add(textBoxDisabled); stackPanel.Children.Add(slider); stackPanel.Children.Add(progressBar); stackPanel.Children.Add(progressBarIndeterminate); var scrollViewer = new ScrollViewer { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Content = stackPanel, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled, Margin = new Vector4F(24, 0, 8, 0) }; var layoutRoot = new StackPanel { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Margin = new Vector4F(0, 0, 0, 0), }; layoutRoot.Children.Add(titlePanel); layoutRoot.Children.Add(scrollViewer); Content = layoutRoot; // Add a context menu MenuItem item0 = new MenuItem { Content = new TextBlock { Text = "Item 0" }, }; MenuItem item1 = new MenuItem { Content = new TextBlock { Text = "Item 1" }, }; MenuItem item2 = new MenuItem { Content = new TextBlock { Text = "Item 2" }, }; MenuItem item3 = new MenuItem { Content = new TextBlock { Text = "Item 3" }, }; MenuItem item4 = new MenuItem { Content = new TextBlock { Text = "Item 4" }, }; ContextMenu = new ContextMenu(); ContextMenu.Items.Add(item0); ContextMenu.Items.Add(item1); ContextMenu.Items.Add(item2); ContextMenu.Items.Add(item3); ContextMenu.Items.Add(item4); }