Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to make Grid Cells clickable in WPF ?

$
0
0

I am new in WPF and learning it by developing full fledged Nepali Calendar using WPF browser application. I've just completed Nepali Bikram Sambat date generation and UI portion.  Now i want to let users to click and add events for any date they want. But don't know how to make each and every cells clickable. I've created grid panel "grdDate" as below.

<Grid Name="grdDate"
      Margin="0,173,353,0"
      Background="#FFF9DB99"
      VerticalAlignment="Stretch"><Grid.ColumnDefinitions><ColumnDefinition Width="10*"  /><ColumnDefinition Width="10*"  /><ColumnDefinition Width="10*" /><ColumnDefinition Width="10*" /><ColumnDefinition Width="10*" /><ColumnDefinition Width="10*" /><ColumnDefinition Width="10*" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="20*" /><RowDefinition Height="20*" /><RowDefinition Height="20*" /><RowDefinition Height="20*" /><RowDefinition Height="20*" /><RowDefinition Height="20*" /></Grid.RowDefinitions></Grid>


I added two TextBlocks  using code behind in every grid cell to display Nepali and English date respectively.

TextBlock txtNday = new TextBlock() 
{ 
          FontSize = 25, 
          Width = 30, 
          VerticalAlignment = VerticalAlignment.Top,   
          HorizontalAlignment = HorizontalAlignment.Center
 };
TextBlock txtEday = new TextBlock() 
{ 
           FontSize = 10, 
           Width = 30, 
           VerticalAlignment = VerticalAlignment.Top, 
           HorizontalAlignment = HorizontalAlignment.Right 
};

Now all I want is to add Click Event to every Grid Cells and popup a window to add new appointments for that date. Please help !!!

Thanks in advance.


Hem Sagar Pokhrel Intern, Braindigit IT Solutions Pvt. Ltd. Kathmandu, Nepal



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>