Hello,
I would like to enable the user changing the IsTabStop property of the columns.My idea is to allow right-click on the header which flips the associated fields IsTabStop value.To visualize the current state, the header text should be colored different according to the current state.
How can I get this?
Thank you!
Hello J_Feuerstein,
Thank you for the feedback. I am glad that you have found a solution to your issue.
Hello Gergana,
I've tried out your solution, but it did not fit into my needs.But I was able to modify it as I need it.First, the IsTabStop property of the Field was what I want to bind the header look to.So I modified the triggers as follows:
<!-- Style for the Header Labels, will display BOLD text for fields with IsTabStop=True --> <Style TargetType="{x:Type igDP:LabelPresenter}"> <EventSetter Event="PreviewMouseRightButtonDown" Handler="LabelPresenterPreviewMouseRightButtonDownHandler" /> <Style.Triggers> <DataTrigger Binding="{Binding Path=Field.IsTabStop, RelativeSource={RelativeSource Self}}" Value="False"> <Setter Property="FontWeight" Value="Normal" /> </DataTrigger> <DataTrigger Binding="{Binding Path=Field.IsTabStop, RelativeSource={RelativeSource Self}}" Value="True"> <Setter Property="FontWeight" Value="Bold" /> </DataTrigger> </Style.Triggers> </Style>
Second, I had to update the IsTabStop property of the associated field.This is bound to a property of the viewmodel, so I have to update the source property.
/// <summary>
/// Flip the IsTabStop property of the field associated to the LabelPresenter. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LabelPresenterPreviewMouseRightButtonDownHandler(object sender, MouseButtonEventArgs e) { var labelPresenter = sender as LabelPresenter; if (labelPresenter == null) return;
var field = labelPresenter.Field; if (field == null) return;
var bindingExpression = BindingOperations.GetBindingBLOCKED EXPRESSION; } }
Maybe this is of some help for anyone else.
I am just checking if you have any further questions on this matter. Please do not hesitate to let me know if you do.
Thank you for your post!
I have been looking into your issue and have created a small sample application for you. In the sample I have a simple XamDataGrid bind to a collection. Then I have created a Style for the LabelPresenter in the Resources of the XamDataGrid. In this style I have EventSetter for the PreviewMouseRightButtonDown and two Triggers for the two states of the IsTabStop property.
In the handler of the PreviewMouseRightButtonDown event I am checking the IsTabStop property and set it to true or false.
Please find the attached sample application and feel free to let me know if you have any further questions on this matter.