#938 – Changing the Selected Text Color in a TextBox

You can change the color of the brush that is used to show selected text in a TextBox by setting the SelectionBrush property.  You’ll typically set this property in XAML to the name of the color that you want the text selection rendered in.  This property defaults to a SolidColorBrush whose color is hex 3399FF (R=51, G=153, B=255), or light blue.

        <TextBox Name="txtTest" Margin="5" Height="100"
            Text="{Binding SomeText}"

The opacity used by the selection brush defaults to 0.4, but you can set it to be more (>0.4) or less (<0.4) opaque by changing the SelectionOpacity property.

        <TextBox Name="txtTest" Margin="5" Height="100"
            Text="{Binding SomeText}"



#905 – Executing Some Code when a User Changes Tabs on a TabControl

You can execute some code whenever a user changes tabs on a TabControl by handling the TabControl’s SelectionChanged event.  Below we have a TabControl and we define a handler for its SelectionChanged event.

    <Grid Margin="10">
            <RowDefinition Height="Auto"/>

        <TabControl SelectionChanged="TabControl_SelectionChanged">
            <TabItem Header="Breakfast">
                    <RadioButton Content="Eggs"/>
                    <RadioButton Content="Cereal"/>
                    <RadioButton Content="Spam"/>
            <TabItem Header="Lunch">
                    <RadioButton Content="Ham Sandwich"/>
                    <RadioButton Content="Soup"/>
                    <RadioButton Content="Wimpy Burger"/>
        <TextBlock Grid.Row="1" Name="txtMessage" Margin="0,5,0,0"/>

In our event handler, we simply change a text message, based on the tab that’s currently selected.

private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
    if ((sender as TabControl).SelectedIndex == 0)
        txtMessage.Text = "Start the day with a good breakfast";
        txtMessage.Text = "Have something healthy for lunch";


#514 – Different Ways to Select Objects in Blend

There are several different ways to select an object on the artboard in Blend, so that you can then change its properties.

Method #1 – Left-click object on artboard when using Selection Tool

Method #2 – With the Selection Tool enabled, left-click and drag to select multiple objects.

Method #3 – Select and object in the Objects and Timeline panel.

Method #4 – Left-click within a XAML element in the XAML editor.