You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I set the headers to hidden using either ShowColumnHeaders="False" or by some other method like setting the height of the header to 0, this collapses the column to minimal size if the column with is set to Star.
Images for illustrating the problem,
With Header visible:
The cells width expands to use the entire available horizontal space, as is the wanted behaviour.
When header is hidden:
The cells with is cut off to what I assume is the MinWidth of either the column or the item.
This is not the wanted behaviour. I expect this is caused by some width calculation involving the header width, which fails in case the header is hidden.
I'll include the code I used to to sets up the columns:
Code
publicHierarchicalTreeDataGridSource<ITreeDataGridSourceFileNode>Tree=>new(GetTreeData()){Columns={newHierarchicalExpanderColumn<ITreeDataGridSourceFileNode>(newTextColumn<ITreeDataGridSourceFileNode,string>("With Header",x => x.FileName.ToString(),
width:new GridLength(1, GridUnitType.Star)),x => x.Children)}};protectedvirtual ITreeDataGridSourceFileNode GetTreeData()=> CreateTestTree();privatestatic ITreeDataGridSourceFileNode CreateTestTree(){varfileEntries=newDictionary<RelativePath,int>{{new RelativePath("Some very long file name that takes most of the screen and should show .bsa"),1},{new RelativePath("BWS - Textures.bsa"),2},{new RelativePath("Readme-BWS.txt"),3},{new RelativePath("Textures/greenBlade.dds"),4},{new RelativePath("Textures/greenBlade_n.dds"),5},{new RelativePath("Textures/greenHilt.dds"),6},{new RelativePath("Textures/Armors/greenArmor.dds"),7},{new RelativePath("Textures/Armors/greenBlade.dds"),8},{new RelativePath("Textures/Armors/greenHilt.dds"),9},{new RelativePath("Meshes/greenBlade.nif"),10}};vartree=FileTreeNode<RelativePath,int>.CreateTree(fileEntries);returnTreeDataGridSourceFileNode<RelativePath,int>.FromFileTree(tree);}
<TreeDataGridx:Name="ModFilesTreeDataGrid"Width="1"> <!-- 👈 Set a width to positive number -->
In your view code behind:
public YourViewWithGrid(){
InitializeComponent();this.WhenActivated(disposables =>{// Do something to update the TreeDataGrid Sourcethis.WhenAnyValue(view => view.ViewModel).WhereNotNull().Do(PopulateFromViewModel).Subscribe().DisposeWith(disposables);// Reset the control width back to NaN, to default it back as if no// width was specified. ModFilesTreeDataGrid.Width =double.NaN;});}
This forces a recalculation of the columns, leading to a corrected width.
If I set the headers to hidden using either
ShowColumnHeaders="False"
or by some other method like setting the height of the header to 0, this collapses the column to minimal size if the column with is set toStar
.Images for illustrating the problem,
With Header visible:
The cells width expands to use the entire available horizontal space, as is the wanted behaviour.
When header is hidden:
The cells with is cut off to what I assume is the
MinWidth
of either the column or the item.This is not the wanted behaviour. I expect this is caused by some width calculation involving the header width, which fails in case the header is hidden.
I'll include the code I used to to sets up the columns:
Code
Axaml View code:
The text was updated successfully, but these errors were encountered: