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"
Margin="50"
Orientation="Vertical"
Background="AliceBlue"
Padding="35"
>
<TextBlock
x:Name="text_block1"
TextWrapping="WrapWholeWords"
Text="Change This text color by choosing a color from radio btton group."
Margin="0,0,0,10"
FontSize="30"
FontFamily="s"
/>
<TextBlock
Text="Choose a Color."
Margin="10"
FontWeight="Black"
/>
<StackPanel
Orientation="Horizontal"
Background="Orange"
Padding="20"
>
<RadioButton
Content="Red"
Tag="Red"
Checked="Color_RadioButton_Checked"
GroupName="TextColor"
/>
<RadioButton
Content="Green"
Tag="Green"
Checked="Color_RadioButton_Checked"
GroupName="TextColor"
/>
<RadioButton
Content="Blue"
Tag="Blue"
Checked="Color_RadioButton_Checked"
GroupName="TextColor"
/>
<RadioButton
Content="Yellow"
Tag="Yellow"
Checked="Color_RadioButton_Checked"
GroupName="TextColor"
/>
</StackPanel>
</StackPanel>
</Page>
MainPage.xaml.cs
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Windows.UI;
namespace UniversalAppTutorials
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void Color_RadioButton_Checked(object sender, RoutedEventArgs e) {
// Get the instance of clicked RadioButton instance
RadioButton rb = (RadioButton)sender;
if (rb != null && text_block1 != null) {
string selectedColor = rb.Tag.ToString();
switch (selectedColor) {
case "Red":
text_block1.Foreground = new SolidColorBrush(Colors.Red);
break;
case "Green":
text_block1.Foreground = new SolidColorBrush(Colors.Green);
break;
case "Blue":
text_block1.Foreground = new SolidColorBrush(Colors.Blue);
break;
case "Yellow":
text_block1.Foreground = new SolidColorBrush(Colors.Yellow);
break;
}
}
}
}
}




- UWP - PivotItem header with image and text
- UWP - Simple Pivot example
- UWP - Border example
- UWP - Polygon example
- UWP - Rectangle example
- UWP - Get ComboBox selected item
- UWP - ListView multi select example
- UWP - ListView item style example
- UWP - How to change ListView item height
- UWP - ListView alternate item style
- UWP - How to create a ListView programmatically
- UWP - ToggleSwitch example
- UWP - Simple Flyout example
- UWP - Simple ContentDialog example
- UWP - HyperlinkButton example