I am writing an application in C # / WPF and trying to figure out how to bind the width of the grid column definitions to a fraction of the screen width. Is it possible? Essentially, I want something like this:
Grid = 2x2
Row 1 Height = 2/3 of the screen height
Row 2 Height = 1/3 of the screen height
Row 1 Width = 2/3 of the screen width
Row 2 Width = 1/3 of the screen width
I think this correctly binds the entire width to the column definition:
<ColumnDefinition Width="{Binding ElementName=Window1, Path=Width}"/>
but I donβt know how to do this, is to perform an operation on the value that it receives through data binding ... is this even possible? I feel that this is something that I should be able to code in XAML and not execute programmatically, but I have little experience with user interface design :( I would like something like:
<ColumnDefinition Width="{Binding ElementName=Window1, Path=Width} * 2 / 3"/>
but it is wrong
Should I just write a function to re-arrange the user interface elements each time I change the screen size? I feel this is redundant ... or is there some simple way to do this that I don't know about? Any input is welcome! Thank!
source
share