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
Xamdatagrid size of unbound fields for horizontal orientation

Hi I am using data grid horizontaliy, When I have too much data the columns automatically shrinks, how can I prevent that?

Also Is the a way to make columns unclickable,

and horizontal way of highlight alternate records?

here is my code

using Infragistics.Windows.DataPresenter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Data;

namespace XamDataGrid_AddColumn
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
        public MainWindow()

        TempVM ViewModel = new TempVM();
        void xamDataGrid_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e)
            List<ISimulatedValue> container = this.ViewModel.Columns;

            e.FieldLayout.Fields.Add(new Field
                Name = "Name",
                Label = "Index",
                AllowEdit = false,
                Height = new FieldLength(200),
                Width = new FieldLength(20)

            int size = 0;

            //  Find the longest array.
            foreach (ISimulatedValue sim in container)
                size = Math.Max(size, sim.AllValues.Length);
            //  Create a field for each value in the longest array.
            for (int i = 0; i < size; i++)
                var field = new NumericField
                    Label = i,
                    AlternateBinding = new Binding(String.Format("{0}[{1}]", nameof(ISimulatedValue.AllValues), i)),
                    AllowEdit = false,
                    Height = new FieldLength(200)
                    //Format = "P2"

                field.Settings.EditAsType = typeof(String);


    public class TempVM
        public TempVM()
            Columns = new List<ISimulatedValue>();
            Columns.Add(new Values("New Name", 100));
            Columns.Add(new Values("New Name2", -100));

        public List<ISimulatedValue> Columns { get; set; }

    public class Values : ISimulatedValue
        public Values(string name, int ratio)
            Name = name;

            //  Generate the sample array data.
            List<double> list = new List<double>();

            for (int i = 0; i < 100; ++i)
                list.Add(ratio * i);
            AllValues = list.ToArray<double>();

        public string Name { get; set; }
        public double[] AllValues { get; set; }

    public interface ISimulatedValue
        string Name { get; set; }
        double[] AllValues { get; set; }

<Window x:Class="Slb.WesternGeco.RockPhysics.Simulation.Views.SpreadsheetView"
        <igDP:XamDataGrid  DataSource="{Binding Path=Data}" GroupByAreaLocation="None" 
                <igDP:GridViewSettings Orientation="Horizontal"></igDP:GridViewSettings>
                <igDP:FieldLayoutSettings AutoGenerateFields="False"
                                        HighlightAlternateRecords ="True"/>

No Data
  • 33730
    Verified Answer
    Offline posted

    Hello Guray,

    I have been investigating into your requirements in this case, and I can say that the reason that the Fields are shrinking in the XamDataGrid is because of your setting of the “AutoFitMode = ‘Always’” in the XamDataGrid.FieldLayoutSettings. This will try to fit all of the Fields in the span (height, in this case) of the grid. The Height in this case will not be respected, and this is expected behavior.

    Regarding highlighting the alternate records, I am assuming that you are looking to have the elements highlighted horizontally – that is, across each cell for a particular Field, as you currently have the FieldLayoutSettings.HighlightAlternateRecords property set to true. In Horizontal orientation, this will highlight vertically, as the records are stacked horizontally. In order to highlight horizontally, I would recommend defining a Style for CellValuePresenter that sets the background property. You can then apply this style to your alternating Field.CellValuePresenterStyle properties.

    Regarding making columns unclickable, are you referring to the Field headers or perhaps the arrows at the top of each record? If you are referring to the arrows, you can shut this off by setting the FieldLayoutSettings.RecordSelectorLocation to “None.” The column headers can be managed using a LabelPresenter style and setting IsHitTestVisible = false.

    I have created a sample project from the code that you have provided and I am attaching it here to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

No Data