tags:

views:

33

answers:

1

hello all i have a problem i have some dynamic button and i want to put some style on it like my other button(Xaml button).how can i fetch the xaml code using c#? but it gives N ERROR

 buttonlanguage.Style = (Style)Application.Current.FindResource("Glassbutton");
A: 

Put your style in the resources section in xaml and call from code-behind like this:

myDynamicButton.Style = (Style)myWindow.FindResource("myButtonStyle");
Veer
but it give en error on mywindow content i put here my windowform name?
Chunmun Tyagi
@SHASHANK: what's the error?
Veer
Glassbutton Resourse not found-- but i put it in resourse
Chunmun Tyagi
in xaml i also used resoursefile
Chunmun Tyagi
there is aneed to give the key for this
Chunmun Tyagi
@SHASHANK: `Glassbutton` should be the key. By the way, where have you defined all the styles. In resource dictionary(separate file) or application.resources/windows.resources(embedded)?
Veer
@SHASHANK: if it is a resourcedictionary you can retrieve it by instantiating ResourceDictionary, setting its source and accessing it like this: `buttonlanguage.Style = (style)myResDic["Glassbutton"];`
Veer
thanks its working
Chunmun Tyagi