Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
XamDataGrid, How can I fix the position of Label?
posted

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>

Parents Reply Children
No Data