In XAMDataGrid..when User click on My Header i want to perfon some action.
e.g. I have Person Record. It has ID and Name which is bound to XAMDataGrid.
Now..when user click on Header ( ID ) ..I want to show dialog box where user wil enter value.
I cant' find a way to do this..
Plz help
thanks
BR
Hello Jaffar,
Could you please be more specific what is your issue and when does it occurs. Also it will be great if you could send us an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Looking forward for your reply.
It suppreses the ungrouping also ..
We have change Orientation of the XamDataGrid.
Below style we have applied on the Label Presenter..
<Style TargetType="{x:Type igDP:LabelPresenter}">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="Header_PreviewMouseLeftButtonDown"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="igDP:LabelPresenter">
<Grid Background="#FFEAEFF1" HorizontalAlignment="Stretch" Margin="-0.5" >
<Rectangle Fill="#FFC2DBF0" Visibility="Hidden" x:Name="rectbackColor" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<TextBlock FontWeight="Bold" Foreground="Black" Margin="5,0,0,0" TextAlignment="Left" HorizontalAlignment="Stretch" Text="{TemplateBinding Content}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>
Now..When our Form loaded... we want to make the "Rectangle" visible for first field of XamDataGrid....
On "Header_PreviewMouseLeftButtonDown" we have change the Rectangular Visible ture and false
if (labelPresenter != null) { Visibility visbility = Visibility.Collapsed; if (IsVisbile) visbility = Visibility.Visible; //Rectangle rectangle = (Rectangle)cellValuePresenterRect.Template.FindName("rectbackColor", cellValuePresenterRect); Rectangle rectangle = (Rectangle)labelPresenter.Template.FindName("rectbackColor", labelPresenter); if (rectangle != null) rectangle.Visibility = visbility; }
I want to Make the Rectangular Visible True when form loaded..
How to do that..?
You could either create a LabelPresenterStyle for the first Field (ID) and use EventSetter to handle the PreviewMouseLeftButtonDown or you can use the EventManager.RegisterClassHandler method to register default handler in codebehind. Note that this could probably disable the sorting on the Field.
<EventSetter Event="PreviewMouseLeftButtonDown"
Handler="lp_PreviewMouseLeftButtonDown"/>
void lp_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("LabelPresenter");
}
Let me know if you have any questions with this matter.