BetaArchive Logo
Total Current Archive Size: 4765.54GB in 15409 files
Navigation Home Screenshots Image Uploader Server Info FTP Servers Wiki Forum RSS Feed Rules Please Donate
UP: 10d, 7h, 41m | CPU: 15% | MEM: 5794MB of 12279MB used
{The community for beta collectors}

Forum rules


Before you post, please make sure...

- ...you have first used Google to look for an answer, and you have asked other people you know via other methods (IM, e-mail, etc).
- ...your question has not been asked before. Search the forum first before posting.

If you meet those criteria, go ahead and post your question. Be sure to provide as much information you can about the problem and how to recreate it. Also provide information on hardware and software if applicable.


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPost subject: C#/WPF - Clickable label/Customizing buttons        Posted: Fri May 18, 2012 3:19 pm 
1337 Beta Collector
1337 Beta Collector
Offline

Joined
Tue Dec 01, 2009 2:56 am

Posts
6087
I have a program I'm working on in C# and WPF. I'd like to have clickable labels, however there is no Click event for a label and I can only find one result on Google when I try to look up how to add a Click event.

So, does anyone know how to add a Click event to a label or, how can I get rid of the button "glow" so it would just *look* like a label in WPF? Either option will work for me, I just can't figure out how to do them.
Image

_________________
Goodbye.


Top  Profile
 PostPost subject: Re: C#/WPF - Clickable label/Customizing buttons        Posted: Fri May 18, 2012 4:34 pm 
Guru Beta Collector
Guru Beta Collector
User avatar
Offline

Joined
Wed Oct 11, 2006 3:17 am

Posts
940

Favourite OS
6.0.5219
You can use the Preview/MouseLeftButtonUp event. It should work.


Top  Profile
 PostPost subject: Re: C#/WPF - Clickable label/Customizing buttons        Posted: Fri May 18, 2012 7:21 pm 
1337 Beta Collector
1337 Beta Collector
Offline

Joined
Tue Dec 01, 2009 2:56 am

Posts
6087
Panda X wrote:
You can use the Preview/MouseLeftButtonUp event. It should work.

That worked quite well for Labels. Thanks :D

_________________
Goodbye.


Top  Profile
 PostPost subject: Re: C#/WPF - Clickable label/Customizing buttons        Posted: Fri May 18, 2012 10:17 pm 
Amateur Beta Collector
Amateur Beta Collector
User avatar
Offline

Joined
Wed Jan 06, 2010 12:40 pm

Posts
134

Location
Germany
In case you are curious or want a more capable/"WPF-ey" solution, I'd advise you to take a look at Templates - they are kinda difficult to grasp, but extremely useful and one of the core concepts in WPF. The solution for your case would be something along these lines:
Code:
<Button Name="LooksLikeALabel" Click="LooksLikeALabel_Click">
    <Button.Template>
        <ControlTemplate TargetType="{x:Type Button}">
            <Label Content="{TemplateBinding Content}" />
        </ControlTemplate>
    </Button.Template>
</Button>

(usually, you'd define the template in a Resources section to make it reusable, but that's a different story)


Top  Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 




Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.

Powered by phpBB® Forum Software © phpBB Group

Copyright © 2006-2013

 

Sitemap | XML | RSS