WPF : How to bind StackPanel height (which is auto) to ImageControl height? - binding

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>

Related

TFS Work Item Form 100% Height

In TFS web interface, is it possible to force a Work Item Form layout to fill 100% height? For example:
Would it be possible in the WIT definition to make it so the tab fills the full height of the form when the form is expanded? There's an option for width to be 100%, but not sure if possible for height.
You need to use "Minimumsize" like following:
<Control FieldName="System.Description" Type="HtmlFieldControl" LabelPosition="Top" Dock="Fill" MinimumSize="(0,465)" />
And you could also use TFS Power Tools to edit the work item
definitions as you can preview the changes with it.
More details and screenshot please refer Eddie's answer here, the value of height as below should be 465.
Besides, there is a Maximize button in the right top corner
After click it, the tab will expand and fills both 100 height and width.

Xamarin.Forms - Expand Width of Column To Longest Content

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>

Adjust height when parent view layout is vertical in appcelerator ios

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>

Why is the width attribute of a XUL button ignored?

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>

Change Silverlight transformation height direction

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".

Resources