automatically same foreground must be changed for all labels RRS feed

  • Question

  • Hai

    I am using Microsoft expression  blend version 2.1.
    In design mode, if i place any number no of  Label
    s in design window.
    automatically same foreground must be changed for all labels.
    how can i do that , can any one please help me,
    its very important
    Friday, October 31, 2008 3:00 PM


  •  In Expression Blend

    First Add a Label on the Window

    Select the Lable using Black Arrow
    Go To Menu Object->Edit Style - Create Empty...

    you will get Popup Dialog "Create Style Resource"
    Give the Name(Key) eg: "LabelStyleDemo"

    in Define in Select the Radio Button "This Document"
    in the dropdown select the option Window:Window
    Click on [OK]

    Now go to [Resources] which is next to [Properties]
    if not visible go to menu Windows->Resources

    You will find "LabelStyleDemo" Style Created under Window 
    DOUBLE CLICK on that

    then go to properties and change the foreground color to red.
    and save it.

    then go to Objects and Timeline Panel
    you will find special button showing [up arrow on horizontal bar icon] - Return Scope to Window.

    you will find the Design window screen like before.

    drag and drop the new labels on the window

    and finally go to Resource Panel
    Select the "LabelStyleDemo" drag and drop on this new label
    you will find a popup menu there you select the option STYLE

    you will get the Same Style Applied to new labels.

    here is the xaml view 3 label using the same resource style.
    instead of drag and drop you can also add the style tag in xaml.

     Width="640" Height="480">
      <Style x:Key="LabelStyleDemo" TargetType="{x:Type Label}">
       <Setter Property="Foreground" Value="#FFF10A0A"/>

     <Grid x:Name="LayoutRoot">

      <Label HorizontalAlignment="Left" Margin="50,88,0,0" VerticalAlignment="Top" Width="184" Height="43" Content="Label" Style="{DynamicResource LabelStyleDemo}"/>

      <Label Margin="50,182,0,222" Content="Label" Style="{DynamicResource LabelStyleDemo}" HorizontalAlignment="Left" Width="169"/>

      <Label Margin="50,135,0,0" VerticalAlignment="Top" Height="43" Content="Label" Style="{DynamicResource LabelStyleDemo}" Width="135" HorizontalAlignment="Left"/>



    Prasad - www.beautifulmind.blog.co.in
    • Proposed as answer by prasad22 Wednesday, December 10, 2008 5:59 PM
    • Marked as answer by Lori DirksModerator Thursday, January 15, 2009 2:16 AM
    Wednesday, December 10, 2008 5:58 PM