button content with a combination of the image

6 posts, 0 answers
  1. Srinivas
    Srinivas avatar
    32 posts
    Member since:
    Aug 2010

    Posted 21 Sep 2010 Link to this post

    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
  2. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 22 Sep 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Srinivas
    Srinivas avatar
    32 posts
    Member since:
    Aug 2010

    Posted 22 Sep 2010 Link to this post



    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






  5. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 23 Sep 2010 Link to this post

    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
  6. Srinivas
    Srinivas avatar
    32 posts
    Member since:
    Aug 2010

    Posted 24 Sep 2010 Link to this post

    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
     
  7. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 28 Sep 2010 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready