Click here to Skip to main content
15,886,689 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Use of Observablecollection in Silverlight Pin
Pete O'Hanlon12-May-11 6:21
mvePete O'Hanlon12-May-11 6:21 
QuestionDataGrid - CheckBox selection from Code. Pin
Nanda_MR10-May-11 18:39
Nanda_MR10-May-11 18:39 
AnswerRe: DataGrid - CheckBox selection from Code. Pin
Pete O'Hanlon10-May-11 19:29
mvePete O'Hanlon10-May-11 19:29 
QuestionOverriding the default keys used to navigate in RadioButtons [WPF] [VB] Pin
Jayme6510-May-11 11:07
Jayme6510-May-11 11:07 
AnswerRe: Overriding the default keys used to navigate in RadioButtons [WPF] [VB] Pin
SledgeHammer0110-May-11 11:55
SledgeHammer0110-May-11 11:55 
GeneralRe: Overriding the default keys used to navigate in RadioButtons [WPF] [VB] Pin
Jayme6510-May-11 12:58
Jayme6510-May-11 12:58 
AnswerRe: Overriding the default keys used to navigate in RadioButtons [WPF] [VB] Pin
Mark Salsbery10-May-11 12:04
Mark Salsbery10-May-11 12:04 
QuestionProblem in VisualTreeHelper.GetParent. Please guide me Pin
Hema Bairavan10-May-11 6:44
Hema Bairavan10-May-11 6:44 
Dear All,

In my application i am using WPF data grid from wpftoolkit. Here in order to achieve one of my requirement i am about to find the parent of the data grid cell.

in my grid i am having an image in an template column.

<my:DataGridTemplateColumn Width="30" >
<my:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Name="imgCalendar" ToolTip="Select" Source="calendar2.jpg" Stretch="Fill" PreviewMouseUp="imgCalendar_PreviewMouseUp"></Image>
</DataTemplate>
</my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>

below is the imgCalendar_PreviewMouseUp event.

Microsoft.Windows.Controls.DataGridCell cell = sender as Microsoft.Windows.Controls.DataGridCell;


Microsoft.Windows.Controls.DataGrid dataGrid = FindVisualParent<Microsoft.Windows.Controls.DataGrid>(cell);


static T FindVisualParent<T>(UIElement element) where T : UIElement
{
UIElement parent = element;
while (parent != null)
{
T correctlyTyped = parent as T;
if (correctlyTyped != null)
return correctlyTyped;

parent = VisualTreeHelper.GetParent(parent) as UIElement;
}

return null;
}


So this is my code.

Now here when ever the grid fills , when i click the image for the first time i am not getting the parent.

But when i click once(i.e for the second time) i am getting the datagrid as parent. I don't know why its happening like this.

Please help me and thanks in advance.
AnswerRe: Problem in VisualTreeHelper.GetParent. Please guide me [modified] Pin
Mark Salsbery10-May-11 8:46
Mark Salsbery10-May-11 8:46 
GeneralRe: Problem in VisualTreeHelper.GetParent. Please guide me Pin
Hema Bairavan10-May-11 22:57
Hema Bairavan10-May-11 22:57 
QuestionRe: Problem in VisualTreeHelper.GetParent. Please guide me Pin
Mark Salsbery11-May-11 4:49
Mark Salsbery11-May-11 4:49 
QuestionWPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Nicolai Schrade10-May-11 5:01
Nicolai Schrade10-May-11 5:01 
AnswerRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Ian Shlasko10-May-11 5:38
Ian Shlasko10-May-11 5:38 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Nicolai Schrade10-May-11 6:00
Nicolai Schrade10-May-11 6:00 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Ian Shlasko10-May-11 6:09
Ian Shlasko10-May-11 6:09 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Nicolai Schrade10-May-11 6:35
Nicolai Schrade10-May-11 6:35 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Ian Shlasko10-May-11 6:52
Ian Shlasko10-May-11 6:52 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Nicolai Schrade10-May-11 22:57
Nicolai Schrade10-May-11 22:57 
AnswerRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Pete O'Hanlon10-May-11 6:35
mvePete O'Hanlon10-May-11 6:35 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Nicolai Schrade10-May-11 22:58
Nicolai Schrade10-May-11 22:58 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Pete O'Hanlon10-May-11 23:46
mvePete O'Hanlon10-May-11 23:46 
QuestionStretch StatusBarItem Pin
Jean-Louis Leroy10-May-11 4:06
Jean-Louis Leroy10-May-11 4:06 
AnswerRe: Stretch StatusBarItem Pin
Ian Shlasko10-May-11 4:35
Ian Shlasko10-May-11 4:35 
GeneralRe: Stretch StatusBarItem Pin
Jean-Louis Leroy10-May-11 5:08
Jean-Louis Leroy10-May-11 5:08 
QuestionDatabinding CheckBox in a ListBox Pin
kurmanc9-May-11 6:30
kurmanc9-May-11 6:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.