locked
Get name of current style RRS feed

  • Question

  • hi,

    I need to get the current style from a button in to a variable name.

    I know you can change the style form a button to a new style.

    button.Style = Application.Current.Resources[syle1] as Style;

    now if you push again on button i want that it shows the name of the style on a label

    I tried this

    label_test.Content = button.Style.ToString();

    but it don't gives the name of the style back


    who can help me


    Wednesday, October 20, 2010 6:13 AM

Answers


  • I found the solution myself

    private void button(object sender, RoutedEventArgs e)
            {
                
                Button b = (Button)sender;
                Style s = b.Style;
                if (s == Application.Current.Resources["style1"])
                {
                }

    if (s == Application.Current.Resources["style2"])
                {
                }

    }

    then you can see if the style from the button equals "style1" or "style2"


    Wednesday, October 20, 2010 8:54 AM

All replies

  • Hi,

    above is only property

    Style st = Application.Current.Resources[syle1] as Style;

    label_test.Content = st.name.tostring();

    Best regrads

    Thaicarrot

    Wednesday, October 20, 2010 8:14 AM

  • I found the solution myself

    private void button(object sender, RoutedEventArgs e)
            {
                
                Button b = (Button)sender;
                Style s = b.Style;
                if (s == Application.Current.Resources["style1"])
                {
                }

    if (s == Application.Current.Resources["style2"])
                {
                }

    }

    then you can see if the style from the button equals "style1" or "style2"


    Wednesday, October 20, 2010 8:54 AM