Skip to main content

Posts

Showing posts from December, 2016

UWP - How to add a Hyperlink to a TextBlock

UWP - Add a Hyperlink to a TextBlock The TextBlock is the primary control for displaying read-only text in UWP apps. The UWP app developers can use it to display single-line or multi-line text, inline hyperlinks, and text with formatting like bold, italic, or underlined. The TextBlock is designed to display a single paragraph and it does not support text indentation. The following Universal Windows Platform application development tutorial demonstrates how we can add a Hyperlink to a TextBlock. Here we will display a Hyperlink inside two TextBlock texts. That means we will put a Hyperlink within the TextBlock text. For the first TextBlock control, we will add a Hyperlink inside the text using the XAML language. And for the second TextBlock control, we will put a Hyperlink within its text programmatically. For the first TextBlock control, we will use inline Run and Hyperlink elements to add a Hyperlink in the text. And for the second Text...

UWP - How to make TextBlock text selectable

UWP - Make TextBlock Text Selectable The TextBlock is the primary control for displaying read-only text in UWP apps. The UWP app developers can use it to display single-line or multi-line text, inline hyperlinks, and text with formatting like bold, italic, or underlined. The TextBlock is designed to display a single paragraph and it does not support text indentation. The following Universal Windows Platform application development tutorial demonstrates how we can enable text selection in a TextBlock control. Here we will set the TextBlock IsTextSelectionEnabled property value to true to enable text selection. We will also handle text selection changes by using the TextBlock SelectionChanged event and display the selected text to another TextBlock control. The TextBlock class IsTextSelectionEnabled property gets or sets a value that indicates whether text selection is enabled in the TextBlock, either through user action or calling selection-rel...

UWP - How to use TextBox SelectionChanged event

UWP - TextBox SelectionChanged Event The TextBox class represents a control that can be used to display and edit plain text. A TextBox can be single or multi-line. The TextBox control enables the UWP app user to enter text into a UWP app. The TextBox is typically used to capture a single line of text but the UWP developers can configure it to capture multiple lines of text. The text displays on the screen in a simple uniform plaintext format. The following Universal Windows Platform application development tutorial demonstrates how we can use the TextBox SelectionChanged event. Here we displayed the TextBox selected text on a TextBlock control when the TextBox selection changed. The TextBox SelectionChanged event occurs when the text selection has changed. The TextBox SelectionChanged event type is RoutedEventHandler. The RoutedEventHandler delegate represents the method that will handle routed events. The RoutedEventHandler(object sende...

UWP - How to use TextBox TextChanged event

UWP - TextBox TextChanged Event The TextBox class represents a control that can be used to display and edit plain text. A TextBox can be single or multi-line. The TextBox control enables the UWP app user to enter text into a UWP app. The TextBox is typically used to capture a single line of text but the UWP developers can configure it to capture multiple lines of text. The text displays on the screen in a simple uniform plaintext format. The following Universal Windows Platform application development tutorial demonstrates how we can use the TextBox TextChanged event. Here we displayed the TextBox entered text on a TextBlock control when the TextBox text changed. The TextBox TextChanged event Occurs when content changes in the text box. The TextBox TextChanged event type is TextChangedEventHandler. The TextChangedEventHandler delegate represents the method that will handle the TextChanged event. The TextChangedEventHandler(object sender,...

UWP - TextBox ScrollBar example

MainPage.xaml <Page x:Class="UniversalAppTutorials.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:UniversalAppTutorials" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" > <StackPanel Padding="50" Background="AliceBlue"> <TextBox x:Name="TextBox1" PlaceholderText="Input some names here" Header="Names" Margin="5" AcceptsReturn="True" TextWrapping="Wrap" MaxHeight="100" ScrollViewer.VerticalScrollBarVisibility="Auto" /> <TextBox ...

UWP - How to change TextBox style

UWP - Change TextBox Style The TextBox class represents a control that can be used to display and edit plain text. A TextBox can be single or multi-line. The TextBox control enables the UWP app user to enter text into a UWP app. The TextBox is typically used to capture a single line of text but the UWP developers can configure it to capture multiple lines of text. The text displays on the screen in a simple uniform plaintext format. The following Universal Windows Platform application development tutorial demonstrates how we can set or change the TextBox styles. Here we will change two TextBoxes styles. For the first TextBox control, we will change its styles by using XAML properties. And for the second TextBox control, we will change its various style properties programmatically. The TextBox class FontFamily property gets or sets the font used to display text in the control. This TextBox property is inherited from Control. This property v...

UWP - Select TextBox all text when get focus

UWP - Select TextBox all text on focus The following Universal Windows Platform application development tutorial demonstrates how we can select all text of a TextBox when the specified TextBox gets focused. In this UWP tutorial, we will handle the TextBox class GotFocus event to select all text of this TextBox instance. We will use the TextBox class SelectAll() method to select TextBox all text when TextBox is focused. The TextBox class represents a control that can be used to display and edit plain text. A TextBox can be single or multi-line. The TextBox control enables the UWP app user to enter text into a UWP app. The TextBox is typically used to capture a single line of text but the UWP developers can configure it to capture multiple lines of text. The text displays on the screen in a simple uniform plaintext format. The TextBox GotFocus event occurs when the TextBox UIElement receives focus. The GotFocus event is raised asynchron...

UWP - How to create a multiline TextBox

UWP - Multiline TextBox The TextBox class represents a control that can be used to display and edit plain text. A TextBox can be single or multi-line. The TextBox control enables the UWP app user to enter text into a UWP app. The TextBox is typically used to capture a single line of text but the UWP developers can configure it to capture multiple lines of text. The text displays on the screen in a simple uniform plaintext format. The following Universal Windows Platform application development tutorial demonstrates how we can create/display a multiline TextBox. The AcceptReturns and TextWrapping properties control whether the TextBox displays text on more than one line. The TextBox class AcceptsReturn property gets or sets the value that determines whether the text box allows and displays the newline or return characters. This property value is a Boolean. The property value is true if the text box allows newline characters otherwise the value ...

UWP - How to change TextBox background color

UWP - Change TextBox background color The TextBox class represents a control that can be used to display and edit plain text. A TextBox can be single or multi-line. The TextBox control enables the UWP app user to enter text into a UWP app. The TextBox is typically used to capture a single line of text but the UWP developers can configure it to capture multiple lines of text. The text displays on the screen in a simple uniform plaintext format. The following Universal Windows Platform application development tutorial demonstrates how we can set or change the TextBox background color. Here we will wrap the TextBox control with a Border control. Then We will set the Border control’s background color. This color will be displayed as the TextBox control’s background color. We will also set the TextBox background color programmatically when it gets focused. The Border class draws a border, background, or both, around another object. The Border cl...

UWP - Vertical FlipView example

MainPage.xaml <Page x:Class="UniversalAppTutorials.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:UniversalAppTutorials" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" > <FlipView x:Name="FlipView1" Background="OldLace" Padding="25" > <!--- Make Vertical FlipView --> <FlipView.ItemsPanel> <ItemsPanelTemplate> <!-- Use vertical stack panel to create vertical flip view --> <VirtualizingStackPanel Orientation="Vertical"/> </ItemsPanelTemplate> </FlipView.ItemsPanel> ...

UWP - FlipView SelectionChanged event example

MainPage.xaml <Page x:Class="UniversalAppTutorials.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:UniversalAppTutorials" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" > <RelativePanel Background="MintCream"> <TextBlock x:Name="TextBlock1" RelativePanel.AlignBottomWithPanel="True" RelativePanel.AlignHorizontalCenterWithPanel="True" Margin="15" Foreground="Blue" FontFamily="MV Boli" FontSize="30" FontStyle="Italic" /> <FlipView x:Na...

UWP - Simple FlipView example

MainPage.xaml <Page x:Class="UniversalAppTutorials.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:UniversalAppTutorials" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" > <FlipView Background="Honeydew" Padding="25"> <!-- Item 1 --> <Viewbox MaxWidth="200" MaxHeight="200"> <SymbolIcon Symbol="Admin" Foreground="Red"/> </Viewbox> <!-- Item 2 --> <Viewbox MaxWidth="200" MaxHeight="200"> <SymbolIcon Symbol="Account" Foreground="Blue"/> </Viewbox> ...

UWP - How to exit an app

UWP - Exit an app The following Universal Windows Platform application development tutorial demonstrates how we can exit from an app. In this UWP tutorial, we will call the CoreApplication class Exit() method to exit the app. We also get the current application object and call its Exit() method to exit the app. The CoreApplication class enables apps to handle state changes, manage windows, and integrate with a variety of UI frameworks. The CoreApplication class Exit() method shuts down the app. The Application class encapsulates a Windows Presentation Foundation application. The Application implements the singleton pattern to provide shared access to its window, property, and resource scope services. Consequently, only one instance of the Application class can be created per AppDomain. The Application class Current property gets the Application object for the current AppDomain. This property value is the Application object for the ...

UWP - How to resize app window during runtime

UWP - Resize app window at runtime The following Universal Windows Platform application development tutorial demonstrates how we can resize an app window during runtime. In this UWP tutorial, we will call the ApplicationView class GetForCurrentView() method to get the active application view instance. Then we will call TryResizeView() method to change the app window size during runtime. The ApplicationView class represents the active application view and associated states and behaviors. The ApplicationView class GetForCurrentView() method gets the view state and behavior settings of the active application. This method returns an ApplicationView instance that can be used to get and set app display properties. The ApplicationView class TryResizeView(Size) method attempts to change the size of the view to the specified size in effective pixels. The TryResizeView(Size value) method has a parameter names value. The value parameter is Siz...

UWP - How to launch app in full screen mode

UWP - Launch the app in full-screen mode The following Universal Windows Platform application development tutorial demonstrates how we can launch an app in full-screen mode. In this UWP tutorial, we will set the ApplicationView class PreferredLaunchWindowingMode property value to FullScreen to launch the app in full-screen mode. The ApplicationView class represents the active application view and associated states and behaviors. The ApplicationView class PreferredLaunchWindowingMode property gets or sets a value that indicates the windowing mode the app launches with. This property value is an ApplicationViewWindowingModeenumeration value that indicates the windowing mode of the app. By default, PreferredLaunchWindowingMode is set to Auto. The ApplicationViewWindowingMode enumeration defines constants that specify whether the app window is auto-sized, full-screen, or set to a specific size on launch. The enumeration value Ful...

UWP - How to set app launch window size

UWP - Set app launch window size The following Universal Windows Platform application development tutorial demonstrates how we can set the app launch window size programmatically. In this UWP tutorial, we will set the ApplicationView class PreferredLaunchViewSize property value to set the app window preferred launch view size. We will also set the ApplicationView class PreferredLaunchWindowingMode property value to set the app window preferred launch windowing mode. The ApplicationView class represents the active application view and associated states and behaviors. The ApplicationView class PreferredLaunchViewSize property gets or sets the size that the app launches with when the ApplicationView class PreferredLaunchWindowingMode property is set to PreferredLaunchViewSize, except in cases where the system manages the window size directly. The PreferredLaunchViewSize property value is a Size. The ApplicationView class PreferredLau...

UWP - How to set app window minimum size

UWP - Set app window minimum size The following Universal Windows Platform application development tutorial demonstrates how we can set the app window minimum size programmatically. Here we will get the current application view. Then we will set the minimum size for this app window using the ApplicationView class SetPreferredMinSize() method. The ApplicationView class represents the active application view and associated states and behaviors. The ApplicationView class GetForCurrentView() method gets the view state and behavior settings of the active application. This method returns an ApplicationView instance that can be used to get and set app display properties. The ApplicationView class SetPreferredMinSize(Size) method sets the smallest size, in effective pixels, allowed for the app window. The SetPreferredMinSize(Size minSize) method has a parameter named minSize. The minSize parameter value is a Size that is the smallest size allowed for ...

UWP - Get app screen size

MainPage.xaml <Page x:Class="UniversalAppTutorials.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:UniversalAppTutorials" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" > <StackPanel Background="Crimson" Padding="50"> <TextBlock x:Name="TextBlock1" FontFamily="MV Boli" FontSize="30" Foreground="Snow" TextWrapping="Wrap" /> </StackPanel> </Page> MainPage.xaml.cs using Windows.UI.Xaml.Controls; using Windows.UI.ViewManagement; using Windows.Graphics.Display; using Windows.Foundation; nam...

UWP - How to hide title bar

UWP - Hide the title bar programmatically The following Universal Windows Platform application development tutorial demonstrates how we can hide the title bar programmatically. Here we will get the application view for the current view. Then we will get the title bar of the application view. After getting the title bar we will set the title bar background color to transparent color. We also extend the core application view into the title bar. As a result, the title bar will be hidden. The ApplicationView class represents the active application view and associated states and behaviors. The ApplicationView class GetForCurrentView() method gets the view state and behavior settings of the active application. This method returns an ApplicationView instance that can be used to get and set app display properties. The ApplicationView class TitleBar property gets the title bar of the app. This property value is an ApplicationViewTitleBar which is the ...

UWP - How to change title bar text

UWP - Change the title bar text programmatically The following Universal Windows Platform application development tutorial demonstrates how we can set or change the title bar text programmatically. Here we will get the application view for the current view. Then we will set the title text for the application view. The ApplicationView class represents the active application view and associated states and behaviors. The ApplicationView class GetForCurrentView() method gets the view state and behavior settings of the active application. This method returns an ApplicationView instance that can be used to get and set app display properties. The ApplicationView class Title property gets or sets the displayed title of the window. This Title property value is a String which is the title of the window. So finally, using this ApplicationView Title property the UWP app developers can change the title bar text programmatically. When the Title pro...

UWP - How to change title bar color

UWP - Change TitleBar Color The following Universal Windows Platform application development tutorial demonstrates how we can programmatically customize/change the title bar color. Here we will get the application view for the current view. Then we will get the title bar of the application view. After getting the title bar we will change the title bar’s various colors. The ApplicationView class represents the active application view and associated states and behaviors. The ApplicationView class GetForCurrentView() method gets the view state and behavior settings of the active application. This method returns an ApplicationView instance that can be used to get and set app display properties. The ApplicationView class TitleBar property gets the title bar of the app. This property value is an ApplicationViewTitleBar which is the title bar of the app. The ApplicationViewTitleBar class represents the title bar of an app. The Applicatio...

UWP - Segoe MDL2 Assets programmatically

MainPage.xaml <Page x:Class="UniversalAppTutorials.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:UniversalAppTutorials" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" > <StackPanel Orientation="Vertical" Background="AliceBlue" Padding="50"> <TextBlock x:Name="TextBlock1" /> <TextBlock x:Name="TextBlock2" /> <TextBlock x:Name="TextBlock3" /> </StackPanel> </Page> MainPage.xaml.cs using Windows.UI.Xaml.Controls; using Windows.UI.Xaml; using Windows.UI.Xaml.Media; using...