In iOS is there a UIView to lay out two child views in a column (or row) such that one view has a fixed height (or width) and the other view expands to fill the empty space?
WPF has the System.Windows.Controls.Grid class, for example. I would use it to solve this problem as follows:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="123" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="I have a fixed height" />
<Label Grid.Row="1" Content="My height expands to fill the empty space" />
</Grid>
Related
In Xamarin Forms, I want to create a 2-column table where the first column expands to the width of the cell with the longest content, like:
What's the best way to accomplish this in Xamarin.Forms?
Make the first column 'auto' and the second '*'. According to the docs auto should be the size of its children and * will take the remaining space.
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
I have one window it's layout is vertical,i have added two child views for that window ,those views height will dynamically change.After adding the views to window,First view is not fit to it's contents some gap is coming.Please help me how to solve this.
below is my code
<Alloy>
<NavigationWindow id="profBidPostNav" platform="ios">
<Window id="profBidPostWin" layout="vertical">
<View id="MainView" height="Ti.UI.SIZE"></View>
<View id="customerServiceMainView" height="Ti.UI.SIZE" top="0%"></View>
</Window>
</NavigationWindow>
Can you add a screenshot to see the problem ?
I see two errors on your code, hieght instead of height and top="0%". If your Window have vertical layout, no need to add top property.
<Window id="profBidPostWin" layout="vertical">
<View id="MainView" height="Ti.UI.SIZE"></View>
<View id="customerServiceMainView" height="Ti.UI.SIZE"></View>
</Window>
I have problems to set the width of my XUL button. I have this code:
<button label="Ok" width="16" maxwidth="16" height="16" maxheight="16"/>
By with that code, the size of my entire window is changed and not only the button.
And when I write that :
<button label="Ok" width="16" height="16"/>
Only the height is changed. Why is that?
XUL uses the flexible box model for positioning. The width and height attributes define the intrinsic size of the element, not the size at which they are displayed. Your button is apparently placed in a vertical box (not necessarily the actual vbox element, rather any element with orient="vertical"). By default, the align attribute of a box is assumed to have the value stretch - so a vertical box will always stretch the elements inside it horizontally:
<vbox>
<!-- this button is stretched horizontally to match the width of its container -->
<button label="Ok" width="16" height="16"/>
</vbox>
You can set the align attribute explicitly to avoid this:
<vbox align="center">
<!-- this button is centered inside its container -->
<button label="Ok" width="16" height="16"/>
</vbox>
I have stackPanel created in design (xmal) which has Auto height and width. Adding list of image controls dynamically in Code on Load to stackPanel. Now it works fine. But when i try to resize the window, though the stack panel gets resized due to auto, but not the image contrl.
How to bind the actualheight of stackpanel dynamically to image control height, (so when ever stakpanl height gets changed ,image control also should get changed !!).
thanks
Use a ViewBox
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Viewbox MaxWidth="500" MaxHeight="500" Name="vb1">
<Image Source="tulip_farm.jpg"/>
</Viewbox>
</StackPanel>
How to: Apply Stretch Properties to the Contents of a Viewbox
Or you could use binding as below:
<StackPanel x:Name="MyStackPanel">
<Image Source="C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg" Stretch="Uniform" Height="{Binding ElementName=MyStackPanel, Path=ActualHeight}"></Image>
</StackPanel>
Here's my xaml
<Button x:Name="btnTest" Width="88" Content="{Binding Value, ElementName=slSlider}" Height="{Binding Value, ElementName=slSlider}" HorizontalAlignment="Left" ></Button>
<Slider x:Name="slSlider" SmallChange="1" LargeChange="10" Maximum="100" Height="32" VerticalAlignment="Top" UseLayoutRounding="False" d:LayoutRounding="Auto" HorizontalAlignment="Left" Width="256" ></Slider>
Very simple stuff. Now what I want to do is restrict the button to only grow in an upwards direction, instead of growing both upwards and downwards. How's this done?
Thanks
Set a MinWidth or MinHeight. There's also MaxWidth and MaxHeight if you need them.
Although re-reading your question I am unsure if you're asking about limiting the minimum size of the button or if you actually are talking about alignment. If you're talking about alignment and you want the top of the button to grow out while the bottom stays in position, set the VerticalAlignment of the Button to "Bottom".