Table like control to set width in percentages
-
Hi all, I'm fiddling around with WPF quite a bit, but i can't seem to get this working: I want four controls in a horizontal row (expanders in this case) to each have 1/4 (25%) of the width of the entire screen (so horizontally they fill up the whole screen, even when resizing..) But here's the catch, the expanders are filled with icons, so when i set width to auto, the expander gets the width depending on how many icons (images) are in the expander's content.. I tried using a grid with colums, but i didnt find out how to set the width to 25% of each column, is there ven a way to do this? Or does another control do what i want? Also tried a stack/wrappanel, but it didnt work out.. Thx
-
Hi all, I'm fiddling around with WPF quite a bit, but i can't seem to get this working: I want four controls in a horizontal row (expanders in this case) to each have 1/4 (25%) of the width of the entire screen (so horizontally they fill up the whole screen, even when resizing..) But here's the catch, the expanders are filled with icons, so when i set width to auto, the expander gets the width depending on how many icons (images) are in the expander's content.. I tried using a grid with colums, but i didnt find out how to set the width to 25% of each column, is there ven a way to do this? Or does another control do what i want? Also tried a stack/wrappanel, but it didnt work out.. Thx
Would a UniformGrid work for you there?
-
Would a UniformGrid work for you there?
I just read something about this, will see if it works, thx! /does exactly the same as a normal grid.. Example of what im doing:
<grid> <expander content="{Staticresource somecontent}" /> <Expander content="{Staticresource somecontent2}" /> <Expander content="{Staticresource somecontent3}" /> <Expander content="{Staticresource somecontent4}"/> </grid>
The resource content is something like this:...
Each expander resizes now to the amount of content (images) in them, which is different for each 1.. Found a solution: <Grid.ColumnDefinitions> <ColumnDefinition Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=2}, Path=ColumnDefinitions[0].Width}" /> <ColumnDefinition Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=2}, Path=ColumnDefinitions[1].Width}"/> <ColumnDefinition Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=2}, Path=ColumnDefinitions[2].Width}"/> <ColumnDefinition Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=2}, Path=ColumnDefinitions[3].Width}"/> </Grid.ColumnDefinitions>modified on Friday, April 11, 2008 3:48 AM