hello,
I want the Label to be fixed at the top like the attached image.
using System.Collections.ObjectModel; using System.Windows; namespace WpfApp1 { public class SampleData { public string PurchaseOrderNumber { get; set; } public string ItemName { get; set; } public int Quantity { get; set; } } public partial class MainWindow : Window { public ObservableCollection<SampleData> SampleDataCollection { get; set; } = new ObservableCollection<SampleData> { new SampleData { PurchaseOrderNumber = "PO100", ItemName = "Item1", Quantity = 100, }, new SampleData { PurchaseOrderNumber = "PO100", ItemName = "Item2", Quantity = 100, }, new SampleData { PurchaseOrderNumber = "PO100", ItemName = "Item3", Quantity = 100, }, new SampleData { PurchaseOrderNumber = "PO200", ItemName = "Item1", Quantity = 100, }, new SampleData { PurchaseOrderNumber = "PO200", ItemName = "Item2", Quantity = 100, }, new SampleData { PurchaseOrderNumber = "PO200", ItemName = "Item3", Quantity = 100, }, new SampleData { PurchaseOrderNumber = "PO300", ItemName = "Item1", Quantity = 100, }, new SampleData { PurchaseOrderNumber = "PO300", ItemName = "Item2", Quantity = 100, }, }; public MainWindow() { InitializeComponent(); } } }
<Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igDP="http://infragistics.com/DataPresenter" DataContext="{Binding RelativeSource={RelativeSource self}}" Title="MainWindow" Height="240" Width="360"> <Grid> <igDP:XamDataGrid x:Name="xamDataGrid" DataSource="{Binding SampleDataCollection}" Theme="Office2013"> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings LabelLocation="Hidden"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:Field Width="100" Label="PO" Name="PurchaseOrderNumber"/> <igDP:Field Width="100" Label="Item" Name="ItemName"/> <igDP:Field Width="75" Label="Q'ty" Name="Quantity" Format="#,0"/> <igDP:FieldLayout.SortedFields> <igDP:FieldSortDescription IsGroupBy="True" FieldName="PurchaseOrderNumber"/> </igDP:FieldLayout.SortedFields> <igDP:FieldLayout.SummaryDefinitions> <igDP:SummaryDefinition SourceFieldName="Quantity" Calculator="Sum" DisplayArea="BottomFixed" StringFormat="{}{0:#,0}"/> </igDP:FieldLayout.SummaryDefinitions> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid> </Grid> </Window>
Hello,
Thank you for posting to Infragistics community!
I have been looking into your question and my suggestion is to set the HeaderPlacementInGroupBy Property of the XamDataGrid’s FieldLayoutSettings object to "OnTopOnly".
However, from the XAML code-snippet, I noticed the LabelLocation property is set to “Hidden” as well. This will prevent any labels from appearing, so my suggestion is to omit it in order for the labels to be shown.
Below you will find a small sample demonstrating this. Please, test it on your side and let me know if it helps achieve your requirement.
Best regards, Bozhidara Pachilova Associate Software Developer
4861.XDGGroupByLabelLocation.zip
It worked for me.
Thank you very much!
I am glad that you find my suggestion helpful. Thank you for using Infragistics components!
Best regards, Bozhidara Pachilova