This is a migrated thread and some comments may be shown as answers.

button content with a combination of the image

5 Answers 483 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Srinivas
Top achievements
Rank 1
Srinivas asked on 21 Sep 2010, 04:52 PM
Hi telerik,
as part of my custom control development for button control, i need to have a button content with a combination of the image
and a text (side by side). i need to change the image to a different image when i place my cursor on to the button and change to
original image when the mouse leaves the control.

how to acheive this in generic.xaml and my cs file?

Regards,
srinivas J

5 Answers, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 22 Sep 2010, 12:27 PM
Hi Srinivas,

 You can use the MouseEnter and MouseLeave events to change the picture in the button.
Could you please examine the attached sample project and tell me if it works for you?

Greetings,
Zarko Vidolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Srinivas
Top achievements
Rank 1
answered on 23 Sep 2010, 04:02 AM


Hello zarko,

Thanks for the reply. but here  my requirement is for custom control development as mentioned  in the earlier mail.the example you provided is useful for application level. I need it at framework level.  I need to acheive this using custom template approach . i need to achieve this in the Generic.xaml .

The end result i would expect something like if i drag and drop my buttoncontrol from toolbox, it should have the default properties like ,

<mycustombutton ......contentimage="someimageurl "  contentname="mybutton" />

if i say like this , then my button should have the feature to take the button image and name on to the button as a content and need to have my image be replaced by new one if i mouse over on it. 
The problem for me is to write the template tag at the generic.xaml. if i get the look then i can write the logic to mouseover and leave.

Help me with your suggestions,

Regards,
Srinivas






0
Zarko
Telerik team
answered on 23 Sep 2010, 05:15 PM
Hello Srinivas,

 I'm sorry for the miss understanding. Please take a look at the project that I've attached , there you can see how to write the template in the Generic.xaml. Notice that in order for this to work you have to register a ResourceDictionary in the App.xaml file.

All the best,
Zarko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Srinivas
Top achievements
Rank 1
answered on 24 Sep 2010, 07:48 PM
Dear Zerko ,
 Thank you very much reply.It helped me. Adding to the below requirement, the buttoncontrol i provide at the framework level which contains image and textblock  placed on the content must have a previlage  to allow the image and textblock 
to arrange themselves to relative height and width with respective to button dimensions( height and width) . is there any properties supports them ?  


Thanks in advance .
Srinivas
 
0
Zarko
Telerik team
answered on 28 Sep 2010, 12:59 PM
Hi Srinivas,

 The Image and the TextBlock are in a StackPanel which fills the whole button, so if you don't explicitly set image size with the ContentImageHeight or ContentImageWidth the sizes of the image and the textblock are going to be relative to the button size. I hope this is what you are looking for and if you have further questions feel free to ask.  

Greetings,
Zarko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Buttons
Asked by
Srinivas
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Srinivas
Top achievements
Rank 1
Share this question
or