Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use click event for label or textblock in wpf c# visual studio?

I am working on desktop application i got suggestion to use wpf instead winforms. I want to go to another form/window when i click my label but i cant find click event for label and textblock? also can anyone tell me what is left mouse up event used for?

like image 741
zareen Avatar asked Apr 21 '17 12:04

zareen


People also ask

What is the difference between TextBlock and label in WPF?

Labels usually support single line text output while the TextBlock is intended for multiline text display. For example in wpf TextBlock has a property TextWrapping which enables multiline input; Label does not have this.

What is TextBlock WPF?

The TextBlock control provides flexible text support for UI scenarios that do not require more than one paragraph of text. It supports a number of properties that enable precise control of presentation, such as FontFamily, FontSize, FontWeight, TextEffects, and TextWrapping.

What are the controls and events in WPF?

There are 23 Controler and 30 above Event are there in Wpf Controler are :- Button,Calendar,CheckBox,ComboBox,ContextMenu,DataGrid,DatePicker,Dialogs,GridView,Image,Label,ListBox,Menus, PasswordBox,Popup,ProgressBar,RadioButton,ScrollViewer,Slider,TextBlock,ToggleButton,ToolTip,Window,3rd Party Controls.


1 Answers

also can anyone tell me what is left mouse up event used for?

It can for example be used to handle the click of a TextBlock like you want:

<TextBlock Text="..." MouseLeftButtonUp="TextBlock_MouseLeftButtonUp" />

This event occurs when the left mouse button is released while the mouse pointer is over this element as stated in the documentation: https://msdn.microsoft.com/en-us/library/system.windows.uielement.mouseleftbuttonup(v=vs.110).aspx

You could also handle the MouseLeftButtonDown event: https://msdn.microsoft.com/en-us/library/system.windows.uielement.mouseleftbuttondown(v=vs.110).aspx

like image 179
mm8 Avatar answered Oct 26 '22 19:10

mm8