locked
Resources - define a style to all textboxes (Claudine Martha Frieda) - 8/2/2007 6:36 AM PST RRS feed

  • Question

  • By: Claudine Martha Frieda

    Hello,
    for one Window I have created a style for a textbox. This style is part of a 
    resource dictionary. Now I want this style to be defined in all textboxes in 
    the other windows of the application. Is is possible to define this 
    afterwords? If not, it would be very complicated to define a style to every 
    textbox in the application. 
    Thanks in advance.
    
    Best regards 
    Claudine
    Wednesday, February 20, 2008 1:23 AM

Answers

  • Just Copy the style in

    app.xaml file

    <Application>
      <Application.Resources>
        ' Copy and rename key, or Move your style here. and save it
      </Application.Resources>
    </Application>
    Prasad - www.beautifulmind.blog.co.in
    • Proposed as answer by prasad22 Wednesday, December 17, 2008 3:07 AM
    • Marked as answer by Lori DirksModerator Thursday, January 15, 2009 2:15 AM
    Wednesday, December 17, 2008 3:07 AM
  • Howdy,
     
    When you create your textbox style, the Create Style Resource dialog gives you the option to apply your style to all textboxes as well as the option to specify the scope.. so you could select Application..

    What this actually does is provides a key for your style if you want it to be named or removes the key attribute so its applied to all elements of the specified type.

    As Prasad correctly showed, you can copy your style to the app.xaml file, all though you dont have to copy and paste it.

    If you open the Resources tab, you should be able to drill into the elements to find the name of the style you created, simply right click and copy the style there and then select the App.xaml and paste it there as well.


    If you have pasted it by hand, simply remove the following attribute from the Style tag:

    x:Key="<<YOUR STYLE NAME>>"

    HTH

    Cheers

    Expression MVP

    Learn Expression Blend at learnexpressionstudio.com

    my blog : http://x-coders.com/blogs/sneaky/default.aspx

    Thursday, December 18, 2008 2:02 AM
    Moderator

All replies

  • Just Copy the style in

    app.xaml file

    <Application>
      <Application.Resources>
        ' Copy and rename key, or Move your style here. and save it
      </Application.Resources>
    </Application>
    Prasad - www.beautifulmind.blog.co.in
    • Proposed as answer by prasad22 Wednesday, December 17, 2008 3:07 AM
    • Marked as answer by Lori DirksModerator Thursday, January 15, 2009 2:15 AM
    Wednesday, December 17, 2008 3:07 AM
  • Howdy,
     
    When you create your textbox style, the Create Style Resource dialog gives you the option to apply your style to all textboxes as well as the option to specify the scope.. so you could select Application..

    What this actually does is provides a key for your style if you want it to be named or removes the key attribute so its applied to all elements of the specified type.

    As Prasad correctly showed, you can copy your style to the app.xaml file, all though you dont have to copy and paste it.

    If you open the Resources tab, you should be able to drill into the elements to find the name of the style you created, simply right click and copy the style there and then select the App.xaml and paste it there as well.


    If you have pasted it by hand, simply remove the following attribute from the Style tag:

    x:Key="<<YOUR STYLE NAME>>"

    HTH

    Cheers

    Expression MVP

    Learn Expression Blend at learnexpressionstudio.com

    my blog : http://x-coders.com/blogs/sneaky/default.aspx

    Thursday, December 18, 2008 2:02 AM
    Moderator