0

I have Gridviewcolumns defined in the GridView. I want to prevent the gridcolumns collapse fully with column re-order enabled. I tried to set minimum width to GridViewColumnHeader but still I could see GridViewColumn collapsed.

I tried to set the IsHitTestVisible="False" but GridViewColumn couldn't achieve it.

RaviG
  • 31
  • 4
  • Please add your Xaml code so people can help you out. – TimvZon Jan 18 '19 at 15:26
  • Possible duplicate of [How apply MinWidth for ListView columns in WPF in control template?](https://stackoverflow.com/questions/10097574/how-apply-minwidth-for-listview-columns-in-wpf-in-control-template) – nosale Jan 18 '19 at 18:18

1 Answers1

1

Finally I was able to set the column size so that they are collapsed on dragging. Here is the sample code I added in code behind.There might be some other way through xaml but I didn't get the way to do it.

 private void connectedReadersListView_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            Thumb senderAsThumb = e.OriginalSource as Thumb;
            GridViewColumnHeader header = senderAsThumb.TemplatedParent as GridViewColumnHeader;
            if (header.Content.ToString() == "System.Windows.Controls.Button: READ" && header.Column.ActualWidth < 60)
            {
                header.Column.Width = 60;
            }
            if (header.Content.ToString() == "System.Windows.Controls.Button: DISCONNECT" && header.Column.ActualWidth < 160)
            {
                header.Column.Width = 160;
            }

            if (header != null && header.Content != null)
            {
                switch (header.Content.ToString().Trim().ToLower())
                {
                    case "reader name":
                        if (header.Column.ActualWidth < 150)
                        {
                            header.Column.Width = 150;
                        }
                        break;
                    case "model":
                        if (header.Column.ActualWidth < 50)
                        {
                            header.Column.Width = 50;
                        }
                        break;
RaviG
  • 31
  • 4