Skip to main content

Posts

Showing posts from January, 2017

UWP - How to use CalendarDatePicker

UWP CalendarDatePicker The CalendarDatePicker class represents a control that allows a UWP app user to pick a date from a calendar display. The UWP app developers can use a CalendarDatePicker to show a drop-down control that is optimized for picking a single date from a calendar view where the fullness of the calendar is important. The CalendarDatePicker control is similar to the DatePicker control, but the DatePicker has no calendar view. The windows app developers can customize the CalendarDatePicker widget with a minimal amount of XAML or other code. The CalendarDatePicker control has an internal calendar view for picking a date. It also has a subset of CalendarView properties to let the windows developers customize it. The CalendarDatePicker DateChanged event occurs when the date value is changed in a CalendarDatePicker widget. So, using this event, the Windows UWP developers can instantly get the CalendarDatePicker control’s selected date. ...

UWP - How to use TimePicker

UWP TimePicker The TimePicker class represents a control that allows a UWP app user to pick a time value. The TimePicker widget gives the app developers a standardized way to let UWP app users pick a time value using touch, mouse, or keyboard input. The Windows UWP app developers can use a TimePicker to let a user enter a single time value. The developers can customize the TimePicker to use a 12-hour or 24-hour clock. The UWP TimePicker control shows a 12-hour clock with an AM PM selector by default. The Windows app developers can set the TimePicker class’s ClockIdentifier property to 24HourClock to show a 24-hour clock instead. The TimePicker class’s TimeChanged event occurs when the value of the Time property is changed. So using this event, the Windows UWP developers can instantly get the TimePicker control’s selected time. The TimePicker class’s Time property allows us to get or set the time currently set in the TimePic...

UWP - Format DatePicker selected date

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 x:Name="stack_panel1" Orientation="Vertical" Background="Snow" Padding="50" > <DatePicker x:Name="DatePicker1" DateChanged="DatePicker1_DateChanged" Header="Select A Date" /> <TextBlock x:Name="TextBlock1" Foreground="Navy" FontSize="21" ...

UWP - How to use DatePicker

UWP DatePicker The DatePicker class represents a control that allows a UWP app user to pick a date value. The UWP app developers can use a DatePicker control to let UWP app users enter a date value. The user picks the date using ComboBox selection for month, day, and year values. The UWP app developers can customize the DatePicker widget’s default look. The DatePicker widget shows the day, month, and year by default. The UWP app developers can hide any field that they don't need. To hide a field from the DatePicker widget, set its corresponding fieldVisible property to false. A DateTimeFormatter creates the string content of each ComboBox in the DatePicker. The .net developers can use a string that is either a format template or a format pattern to specify the format. The DatePicker DateChanged event occurs when the date value is changed in a DatePicker widget. So, using this event, the UWP developers can instantly get the Date...

UWP - How to use PasswordBox

UWP PasswordBox The PasswordBox class represents a control for entering passwords. PasswordBox lets a user enter a masked password. The Windows UWP app users can enter a single line of non-wrapping text in a PasswordBox control. The PasswordBox text is not displayed while it is entered, only masked characters are displayed. The .net developers can specify this password character by setting the PasswordChar property. The PasswordBox class PasswordRevealMode property gets or sets a value that specifies whether the password is always, never, or optionally obscured. This property value is a value of the enumeration that specifies whether the password is always, never, or optionally obscured. The default value of this property is Peek which ensures the password reveal button is visible and the password is not obscured while the button is pressed. The PasswordBox class PasswordChar property gets or sets the masking character for the PasswordBox. ...

UWP - How to set ComboBox default selected item

UWP - Set ComboBox Default Selected Item The ComboBox class represents a selection control that combines a non-editable text box and a drop-down list box that allows UWP app users to select an item from a list. The ComboBox starts in a compact state and it expands to display a list of selectable items. The ComoboBox control is also known as a drop-down list. The following UWP app development tutorial code demonstrates how we can set the ComboBox default selected item. That means we will set an item of ComboBox as its pre-selected item. In this UWP example code, we populate the ComboBox with items from a String data type list. The ItemsControl class’s ItemsSource property gets or sets an object source used to generate the content of the ItemsControl such as a ComboBox control. So we data bind the ComboBox control with a list of String values using this ItemsSource property. Now the part is how we can make an item the default sele...

UWP - ComboBox DisplayMemberPath and SelectedValuePath

UWP - ComboBox DisplayMemberPath and SelectedValuePath The ComboBox class represents a selection control that combines a non-editable text box and a drop-down list box that allows UWP app users to select an item from a list. The ComboBox starts in a compact state and it expands to display a list of selectable items. The ComoboBox control is also known as a drop-down list. The ItemsControl class’s DisplayMemberPath property gets or sets the name or path of the property that is displayed for each data item. This property value is a String instance that is the name or path of the property that is displayed for each data item in the control. The default value of this property is an empty string. The Selector class’s SelectedValuePath property gets or sets the property path that is used to get the SelectedValue property of the SelectedItem property. This property value is also a String object that is the property path that is used to get the Selecte...

UWP - ComboBox item style 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 x:Name="stack_panel1" Orientation="Horizontal" Background="Azure" Padding="125" > <ComboBox x:Name="ComboBox1" Header="Select A Color" Foreground="Crimson" FontSize="22" FontFamily="MV Boli" > </ComboBox> </StackPanel> </Page> MainPage.xam...

UWP - How to get ComboBox selected value

UWP - Get ComboBox Selected Value The ComboBox class represents a selection control that combines a non-editable text box and a drop-down list box that allows UWP app users to select an item from a list. The UWP app developers can use a ComboBox to present a list of items that the app user can select from. The ComboBox starts in a compact state and it expands to display a list of selectable items. The ComoboBox control is also known as a drop-down list. The ComboBox either displays the current selection or is empty if there is no selected item in its closed state. ComboBox displays the list of selectable items in its expanded state. The following UWP app development tutorial code demonstrates how we can get the ComboBox selected value. Here we data bind the ComboBox control with Dictionary items. We also add a selection changed event to the ComboBox control, so we can get the selected item value when the user makes a selection on t...

UWP - How to use ComboBox ItemsSource

UWP - ComboBox ItemsSource The ComboBox class represents a selection control that combines a non-editable text box and a drop-down list box that allows UWP app users to select an item from a list. The ComboBox starts in a compact state and it expands to display a list of selectable items. The ComoboBox control is also known as a drop-down list. The following UWP app development tutorial code demonstrates how we can use the ItemsSource property to data bind a ComboBox control. In this UWP example code, we populate the ComboBox with items from a String data type list. Here we applied a selection changed event for the ComboBox control to get its selected item when the app user makes the selection change. The ItemsControl class’s ItemsSource property gets or sets an object source used to generate the content of the ItemsControl such as a ComboBox control. The ItemsSource property value type is an Object instance. This Object is used to generate ...

UWP - How to use ComboBox ItemTemplate

UWP - ComboBox ItemTemplate The ComboBox class represents a selection control that combines a non-editable text box and a drop-down list box that allows UWP app users to select an item from a list. The ComboBox starts in a compact state and it expands to display a list of selectable items. The ComoboBox control is also known as a drop-down list. The ComboBox control is an ItemsControl that's why the UWP developers can put there a collection of items of any type. By default, the ComboBox data item is displayed as the string representation. The ItemsControl class’s ItemTemplate property gets or sets the DataTemplate used to display each item. ItemTemplate property value is a DataTemplate instance which is the template that specifies the visualization of the data objects. The default value of this property is null. So using this ItemTemplate property the UWP developers can display custom-styled items inside a ComboBox. The DataTem...

UWP - Drawing on a Canvas 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" > <Canvas x:Name="Canvas1" Background="AliceBlue"> </Canvas> </Page> MainPage.xaml.cs using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Shapes; using Windows.UI.Xaml.Media; using Windows.UI; namespace UniversalAppTutorials { public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); DarwOnCanvas(); } void DarwOnCanvas() { // Initialize a new...

UWP - Canvas 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" > <!-- Canvas Defines an area within which you can explicitly position child objects, using coordinates that are relative to the Canvas area. Canvas.ZIndex Gets or sets the Z-order of an element when that element is presented in its parent Canvas layout container. --> <Canvas Background="AliceBlue"> <Ellipse Width="100" Height="100" ...

UWP - ScrollViewer scroll to bottom

UWP - ScrollViewer Scroll To Bottom The ScrollViewer class represents a scrollable area that can contain other visible elements. The ScrollViewer control enables content to be displayed in a smaller area than its actual size. The ScrollViewer displays scrollbars when its content is not entirely visible. In the following UWP tutorial code, we put multiple TextBlock in a StackPanel control whose orientation is vertical. Then we wrap the StackPanel control with a ScrollViewer, so the users can scroll through the bottom of StackPanel content. The UWP developers use ScrollViewer container control to lets the user pan and zoom its content. But in this UWP tutorial code, we will demonstrate how we can scroll to the bottom of ScrollViewer content programmatically. Here we use a Button control and its click event to programmatically scroll to the bottom of StackPanel contents. In this tutorial, we also set the ScrollViewer control’s HorizontalScrol...

UWP - How to use ScrollViewer

UWP ScrollViewer The ScrollViewer class represents a scrollable area that can contain other visible elements. The following UWP app development tutorial code will demonstrate how we can use a ScrollViewer in a UWP application to enable the scrolling capability of the inside elements. Here we put multiple TextBlock in a StackPanel control whose orientation is vertical. Then we wrap the StackPanel control with a ScrollViewer, so the users can scroll through the bottom of StackPanel content. The UWP developers use ScrollViewer container control to lets the user pan and zoom its content. The ScrollViewer control enables content to be displayed in a smaller area than its actual size. The ScrollViewer displays scrollbars when its content is not entirely visible. The ScrollViewer class’s HorizontalScrollBarVisibility property gets or sets a value that indicates whether a horizontal ScrollBar should be displayed in a ScrollViewer. This property value is a ScrollB...

UWP - RelativePanel 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="AliceBlue" Padding="50"> <TextBlock x:Name="SignInText" Text="Sign In" RelativePanel.AlignHorizontalCenterWithPanel="True" Foreground="Black" FontSize="30" FontWeight="Normal" CharacterSpacing="200" /> <TextBox x:Name="UserName" H...

UWP - RelativePanel stretch 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="AliceBlue" Padding="50"> <!-- Stretch element horizontally, parent left to right edge. --> <Rectangle x:Name="Red" Fill="Red" Height="50" RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignRightWithPanel="True" /> <!-- Stretch element ver...

UWP - Understanding RelativePanel elements position

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="AliceBlue" Padding="50"> <Rectangle x:Name="Red" Fill="Red" Width="50" Height="50" RelativePanel.AlignHorizontalCenterWithPanel="True" RelativePanel.AlignVerticalCenterWithPanel="True" /> <Rectangle x:Name="Green" Fill="Green" ...