Windows API Reference

UWP Controls Reference

This section provides a comprehensive reference for common Universal Windows Platform (UWP) controls. These controls are fundamental building blocks for creating modern and responsive user interfaces on Windows.

Button

A clickable button that performs an action when pressed.

public class Button : ContentControl

Key Properties:

  • Content: Gets or sets the content of the button.
  • Command: Gets or sets the command to invoke when the button is clicked.
  • CommandParameter: Gets or sets the parameter to pass to the Command.

Key Events:

  • Click: Raised when the button is clicked.

Example Usage (XAML):

<Button Content="Click Me" Click="MyButton_Click" />

TextBox

A control that allows the user to enter and edit text.

public class TextBox : Control

Key Properties:

  • Text: Gets or sets the current text content of the TextBox.
  • PlaceholderText: Gets or sets the text that is displayed when the TextBox is empty.
  • IsReadOnly: Gets or sets a value indicating whether the TextBox is read-only.
  • MaxLength: Gets or sets the maximum number of characters allowed in the TextBox.

Key Events:

  • TextChanged: Raised when the text in the TextBox changes.
  • Paste: Raised when content is pasted into the TextBox.

Example Usage (XAML):

<TextBox x:Name="MyTextBox" PlaceholderText="Enter your name" />

CheckBox

A control that represents a Boolean value.

public class CheckBox : ToggleButton

Key Properties:

  • IsChecked: Gets or sets a value indicating whether the control is checked.
  • Content: Gets or sets the content of the CheckBox.

Key Events:

  • Checked: Raised when the CheckBox is checked.
  • Unchecked: Raised when the CheckBox is unchecked.

Example Usage (XAML):

<CheckBox Content="Remember me" IsChecked="True" />

RadioButton

A control that allows the user to select one option from a group.

public class RadioButton : ToggleButton

Key Properties:

  • GroupName: Gets or sets the name of the group to which this RadioButton belongs.
  • IsChecked: Gets or sets a value indicating whether the control is checked.
  • Content: Gets or sets the content of the RadioButton.

Key Events:

  • Checked: Raised when the RadioButton is checked.
  • Unchecked: Raised when the RadioButton is unchecked.

Example Usage (XAML):

<StackPanel>
    <RadioButton GroupName="Color" Content="Red" IsChecked="True" />
    <RadioButton GroupName="Color" Content="Blue" />
</StackPanel>
                        

ComboBox

A dropdown list that allows the user to select an item from a collection.

public class ComboBox : Selector

Key Properties:

  • ItemsSource: Gets or sets a collection used to generate the items of the control.
  • SelectedItem: Gets or sets the selected item.
  • SelectedIndex: Gets or sets the index of the selected item.
  • IsEditable: Gets or sets a value that indicates whether the ComboBox is editable.

Key Events:

Example Usage (XAML):

<ComboBox x:Name="MyComboBox" Width="200">
    <ComboBoxItem Content="Item 1" />
    <ComboBoxItem Content="Item 2" />
    <ComboBoxItem Content="Item 3" />
</ComboBox>
                        

ListBox

A control that displays a list of items and allows the user to select one or more items.

public class ListBox : Selector

Key Properties:

  • ItemsSource: Gets or sets a collection used to generate the items of the control.
  • SelectedItem: Gets or sets the selected item.
  • SelectedIndex: Gets or sets the index of the selected item.
  • SelectionMode: Gets or sets the selection mode for the ListBox.

Key Events:

Example Usage (XAML):

<ListBox x:Name="MyListBox" SelectionMode="Multiple">
    <ListBoxItem Content="Option A" />
    <ListBoxItem Content="Option B" />
    <ListBoxItem Content="Option C" />
</ListBox>
                        

GridView

A control that displays a collection of items in a grid layout, with support for virtualization and adaptive sizing.

public class GridView : ItemsControl

Key Properties:

  • ItemsSource: Gets or sets a collection used to generate the items of the control.
  • ItemTemplate: Gets or sets the DataTemplate that defines how items are displayed.
  • SelectedItem: Gets or sets the selected item.

Key Events:

Example Usage (XAML):

<GridView ItemsSource="{x:Bind MyCollection}">
    <GridView.ItemTemplate>
        <DataTemplate x:DataType="local:MyDataItem">
            <StackPanel>
                <TextBlock Text="{x:Bind Name}" />
                <Image Source="{x:Bind ImageUrl}" />
            </StackPanel>
        </DataTemplate>
    </GridView.ItemTemplate>
</GridView>
                        

Image

A control used to display an image.

public class Image : FrameworkElement

Key Properties:

  • Source: Gets or sets the Uniform Resource Identifier (URI) of the image source.
  • Stretch: Gets or sets how the image content should be scaled to fit the destination bounds.
  • Width: Gets or sets the width of the Image element.
  • Height: Gets or sets the height of the Image element.

Example Usage (XAML):

<Image Source="Assets/logo.png" Width="100" Height="100" />

Slider

A control that allows the user to select a value from a range by moving a slider thumb.

public class Slider : RangeBase

Key Properties:

  • Value: Gets or sets the current position of the slider thumb.
  • Minimum: Gets or sets the minimum value of the slider.
  • Maximum: Gets or sets the maximum value of the slider.
  • Orientation: Gets or sets the orientation of the slider.

Key Events:

Example Usage (XAML):

<Slider x:Name="MySlider" Minimum="0" Maximum="100" Value="50" />

ProgressBar

A control that indicates the progress of an operation.

public class ProgressBar : RangeBase

Key Properties:

  • Value: Gets or sets the current progress value.
  • IsIndeterminate: Gets or sets a value indicating whether the progress bar is indeterminate.

Example Usage (XAML):

<ProgressBar x:Name="MyProgressBar" Minimum="0" Maximum="100" Value="75" />

DatePicker

A control that allows the user to select a date.

public class DatePicker : Control

Key Properties:

  • Date: Gets or sets the selected date.
  • CalendarIdentifier: Gets or sets the identifier of the calendar to use.
  • DayVisible: Gets or sets a value indicating whether the day part is displayed.
  • MonthVisible: Gets or sets a value indicating whether the month part is displayed.
  • YearVisible: Gets or sets a value indicating whether the year part is displayed.

Key Events:

Example Usage (XAML):

<DatePicker x:Name="MyDatePicker" />

TimePicker

A control that allows the user to select a time.

public class TimePicker : Control

Key Properties:

  • Time: Gets or sets the selected time.
  • ClockIdentifier: Gets or sets the identifier of the clock to use.
  • Header: Gets or sets the text label for the control.

Key Events:

Example Usage (XAML):

<TimePicker x:Name="MyTimePicker" />