Hi,
I have a grid where some of the numeric columns have set LabelTextAlignment="Right" to right justify the header text.
However in the field chooser dialog the fields are also displayed right justified in the list which looks rather ridiculous. Is there a way to prevent this 'feature'?
Hello marjones,
Thank you for your post. I have been looking through it and I reproduce your behavior. To prevent this feature, I suggest you add the following code in the FieldChooserOpening Event of your xamDataGrid:
e.FieldChooser.CurrentFields[num].Field.Settings.LabelTextAlignment = TextAlignment.Left;
where "num" is the index of the Field, which is zero based. By doing this you will set the TextAlignment Property of a specific field so that all the headers could look the same in the FieldChooser.
If you have any further questions on this matter do not hesitate to ask.
Thanks for that information.
for anyone else with the same problem heres some complete code for a utility class to do it.
static class XamDataGridUtils { public static void LeftJustifyFieldChooserLabels(XamDataGrid grid) { grid.FieldChooserOpening += grid_FieldChooserOpening; } static void grid_FieldChooserOpening(object sender, FieldChooserOpeningEventArgs e) { foreach(var field in e.FieldChooser.CurrentFields) { field.Field.Settings.LabelTextAlignment = TextAlignment.Left; } } }
I have a similar issue but is happening with the headers having horizontal text alignment as center. I have 10 columns out of which 6 are having text as left aligned and the remaining 4 are center aligned. when I apply column chooser, I want to keep all the text as left aligned only in the column chooser. As of now all the columns are appearing as they are appearing in the grid
is there a way I could achieve this. I have attached a sample project to show you the scenario with two columns center aligned. I want both of them to be left aligned only in the column chooser or field chooser.
just to clarify, my doubt is about the second field layout. the code sample you have mentioned gives me only the first fieldgroup and not the second one. Is there a way I could access the second field group as well?
Hello Sandeep,
I have been looking into your sample and I modified it, so now it works as you want. basically I moved the Style for the FieldChooser in the App.xaml file, because the FieldChooser is a separate Window and the Style wasn't applying. I also removed the Style in the FieldChooser's Resources and set the Template directly to the LAbelPresenter. I also set the HorizontalAlignment of the ContentPresenter that is inside the Template to Left. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hi Stefen,
This works perfectly fine for me. Thank you very much.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.