Hi I have this Xamarin Forms app where I have the following layout:
<ContentPage Title="Live" Icon="tv_show-32.png">
<ScrollView>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackLayout Grid.Row="0" Grid.Column="0" Spacing="50,20,50,30">
<Image Source="http://kanal10.se/images/logga/kanal10.png" HorizontalOptions="FillAndExpand"></Image>
</StackLayout>
<StackLayout Grid.Column="0" Grid.Row="1" Style="{StaticResource StackBG}">
<Label Text="Sverige/Sweden"></Label>
<BoxView WidthRequest="100" HeightRequest="1" BackgroundColor="#009fe3"></BoxView>
<Image Source="http://kanal10.se/storage/images/kanal10/kanal-10/tvbild.png" HorizontalOptions="Fill"></Image>
<Button x:Name="Sweden" Text="Watch Live" Clicked="Sweden_OnClicked" HorizontalOptions="FillAndExpand" Style="{StaticResource PlayButtonStyle}"></Button>
</StackLayout>
<StackLayout Grid.Column="0" Grid.Row="2" Style="{StaticResource StackBG}">
<Label Text="Norge/Norway"></Label>
<BoxView WidthRequest="100" HeightRequest="1" BackgroundColor="#009fe3"></BoxView>
<Image Source="http://kanal10.se/storage/images/kanal10/kanal-10/tvbild.png" HorizontalOptions="FillAndExpand"></Image>
<Button x:Name="Norway" Text="Watch Live" Clicked="Norway_OnClicked" HorizontalOptions="FillAndExpand" Style="{StaticResource PlayButtonStyle}"></Button>
</StackLayout>
<StackLayout Grid.Column="0" Grid.Row="3" Style="{StaticResource StackBG}">
<Label Text="Asien/Asia"></Label>
<BoxView WidthRequest="100" HeightRequest="1" BackgroundColor="#009fe3"></BoxView>
<Image Source="http://kanal10.se/storage/images/kanal10/kanal-10/tvbild.png" HorizontalOptions="FillAndExpand"></Image>
<Button x:Name="Asia" Text="Watch Live" Clicked="Asia_OnClicked" Style="{StaticResource PlayButtonStyle}"></Button>
</StackLayout>
</Grid>
</ScrollView>
</ContentPage>
The problem is that I can't get the image called tvbild.png, to fill the whole container in the iOS app.
I would like the image to have the same width size as the button (see attached image).
How can I accomplish this?
Thanks for help!
Peter
Hi and thanks for answer,
Well what I want is to fill the whole conatiners width for both the button and the image.
Peter
Assuming image size is known; use separate row in Grid for image and button and
set HeightRequest for Image and ColumnDefinition Width for Grid, see sample below:
Original image width is 100 and height is 50. Width of container is 300.
Find scale factor based on width of container and width of image: 300/100=3
Find HeightRequest based on scale and height of image: 3*50=150:
<ContentPage Padding="10,20"
...
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Source="100x50.png" HeightRequest="150"/>
<Button Grid.Row="1" Text="Button 1"/>
<Image Grid.Row="2" Source="200x100.png" HeightRequest="150"/>
<Button Grid.Row="3" Text="Button 2"/>
</Grid>
Sample output from iPhone SE simulator with page width 320. The left and right border is from area left and right of the display:
Related
How do I make the CollectionView render all items with the same height while using a GridItemsLayout on iOS? It already works on Android that all elements in a row gets the same height but on iOS they are squished vertically in the center of the row.
This is how it currently looks on iOS (how it not should be..):
And this is how it currently looks on Android (how it also should be on iOS - all elements are scaled to the same height in the same row):
As of now, this is how my XAML looks like:
<CollectionView Grid.Row="1" x:Name="DataListView" ItemSizingStrategy="MeasureAllItems" ItemsSource="{Binding Data}" IsGrouped="False" ItemTemplate="{StaticResource EntryTemplate}"
Header="{Binding Header}" Footer="{Binding Footer}" BackgroundColor="{DynamicResource DarkBackgroundColor}">
<CollectionView.ItemsLayout>
<!-- Span is set in OnSizeAllocated to make this "dynamic" -->
<GridItemsLayout x:Name="GridItemsLayout" Orientation="Vertical" Span="1" />
</CollectionView.ItemsLayout>
<CollectionView.HeaderTemplate>
<DataTemplate x:DataType="x:String">
<Grid Padding="10,20">
<Label Text="{Binding}" TextColor="{DynamicResource TextColor}" FontAttributes="Bold" HorizontalTextAlignment="Center" LineBreakMode="WordWrap" />
</Grid>
</DataTemplate>
</CollectionView.HeaderTemplate>
<CollectionView.FooterTemplate>
<DataTemplate x:DataType="x:String">
<Grid Padding="{OnPlatform iOS=20 30 20 20, Default=20}">
<Label Text="{Binding}" TextColor="{DynamicResource LightTextColor}" FontSize="Micro" HorizontalTextAlignment="Center" LineBreakMode="WordWrap" />
</Grid>
</DataTemplate>
</CollectionView.FooterTemplate>
</CollectionView>
This is my entry data template XAML:
<DataTemplate x:Key="EntryTemplate" x:DataType="data:Entry">
<Grid BackgroundColor="Red" VerticalOptions="FillAndExpand" Margin="0">
<Frame WidthRequest="{Binding Converter={StaticResource FlowColumnWidthConverter}, ConverterParameter=324}" BackgroundColor="{DynamicResource DarkerBackgroundColor}"
BorderColor="{Binding IsActive, Converter={StaticResource ActiveToColorConverter}}" HorizontalOptions="Center" Margin="8" Padding="10" CornerRadius="5">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="OnChecklistElementTapped" />
</Frame.GestureRecognizers>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Grid.Column="0" Grid.RowSpan="4" Source="{Binding Type, Converter={StaticResource TypeToEmbeddedImageConverter}}" WidthRequest="32" HeightRequest="32" Margin="4" />
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Name}" FontAttributes="Bold" LineBreakMode="TailTruncation" VerticalOptions="Start" />
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Region}" FontSize="12" LineBreakMode="TailTruncation" VerticalOptions="Start" Margin="0,-6,0,0" />
<Label Grid.Row="2" Grid.Column="1" Text="{Binding AdditionalData}" TextType="Html" FontSize="12" LineBreakMode="WordWrap" Margin="0"
IsVisible="{Binding AdditionalData, Converter={StaticResource EmptyToVisibilityConverter}}" InputTransparent="True" />
<Label Grid.Row="3" Grid.Column="1" Text="{Binding Description}" FontSize="12" LineBreakMode="WordWrap"
IsVisible="{Binding Description, Converter={StaticResource EmptyToVisibilityConverter}}" />
<Switch Grid.Row="0" Grid.Column="2" Grid.RowSpan="2" IsToggled="{Binding IsDone}" HorizontalOptions="Center" VerticalOptions="Center" />
<StackLayout Grid.Row="2" Grid.Column="2" Grid.RowSpan="2" Orientation="Horizontal" Spacing="12" HorizontalOptions="Center" VerticalOptions="Start" Margin="0,4,0,4">
<controls:TintedImageButton Source="Details.png" Clicked="OnNavigateToDetailsButtonClicked" HeightRequest="32" WidthRequest="32"
IsVisible="{Binding Details, Converter={StaticResource EmptyToVisibilityConverter}}"
HorizontalOptions="Center" BackgroundColor="Transparent" />
<controls:TintedImageButton Source="Map.png" Clicked="OnNavigateToMapButtonClicked" HeightRequest="32" WidthRequest="32"
HorizontalOptions="Center" BackgroundColor="Transparent" IsVisible="{x:Static resources:Metadata.MAP_ENABLED}" />
</StackLayout>
</Grid>
</Frame>
</Grid>
</DataTemplate>
And this is my code behind (where I set how many columns there should be):
protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);
GridItemsLayout.Span = Convert.ToInt32(Math.Floor(width / 340d));
}
Anyone has an idea, why this is looks different on iOS in the first place and what I should look up to fix this problem?
I have a fairly simple Xamarin forms layout.
The layout works as expected as long as I hold the iPhone, but when placed on a flat surface and I then navigate to a specific page the page, gets an incorrectly layout.
The offending page:
<?xml version="1.0" encoding="UTF-8"?>
<pages:BaseContentPage xmlns:pages="clr-namespace:Mainapp.Pages" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:customcontrols="clr-namespace:Mainapp.CustomControls" xmlns:forum="clr-namespace:Mainapp.Pages.Forum" x:Class="Mainapp.Pages.Forum.ForumTopicDetailPage">
<pages:BaseContentPage.MainContent>
<AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="Red" >
<StackLayout AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" BackgroundColor="Blue">
<Grid Padding="65,5,5,5" VerticalOptions="StartAndExpand" HorizontalOptions="FillAndExpand" x:Name="ContentGrid" BackgroundColor="Green">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Label x:Name="LblTopTitle" Style="{StaticResource TitleStyle}" Grid.Row="0" Grid.Column="0" FontAttributes="Bold" FontSize="14" LineBreakMode="WordWrap" HorizontalTextAlignment="Center" MaxLines="2" />
<Label x:Name="LblAuthor" Style="{StaticResource SubTitleStyle}" Grid.Row="1" Grid.Column="0" FontAttributes="None" FontSize="12"/>
<customcontrols:UserInitialsView VerticalOptions="Center" HorizontalOptions="Center" Grid.RowSpan="2" Grid.Column="1" x:Name="UserIntials"></customcontrols:UserInitialsView>
</Grid>
<ListView x:Name="TableListView"
ItemsSource="{Binding Comments}"
HasUnevenRows="true"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
IsVisible="true"
SeparatorColor="Transparent"
SelectionMode="None"
BackgroundColor="{StaticResource BlueBackground}">
<ListView.ItemTemplate>
<DataTemplate>
<forum:TopicCommentCell CommentContent="{Binding}" UserChangedLikeStateForComment="UserChangedLikedStateForContent" />
</DataTemplate>
</ListView.ItemTemplate>
<ListView.Header>
<Grid Padding="0,0,0,10" BackgroundColor="Purple">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label BackgroundColor="{StaticResource Light_Ivory}" Text=""/>
<Frame HasShadow="False" CornerRadius="36" BackgroundColor="{StaticResource Light_Ivory}" Grid.RowSpan="5" />
<Label Padding="10,0,10,0" x:Name="LblListTitle" MaxLines="2" VerticalOptions="Start" Style="{StaticResource Topic_HeadlineStyle}" Grid.Row="1" Text="TITLE" />
<Label Padding="10,0,10,0" x:Name="LblListText" VerticalOptions="Start" Style="{StaticResource Topic_TextStyle}" LineHeight="1.5" Grid.Row="2" Text="TEXT TEXT TEXT"/>
<customcontrols:LikeView Padding="10,20,0,0" x:Name="LikeView" Grid.Row="3" UserChangedLikedState="UserChangedLikedStateForContent"></customcontrols:LikeView>
<Label Padding="10,0,10,0" x:Name="LblCommentHeader" HorizontalTextAlignment="Start" MaxLines="1" VerticalOptions="Start" Style="{StaticResource TitleStyle}" Grid.Row="5" Text="Kommentarer" />
</Grid>
</ListView.Header>
<ListView.Footer>
<Label BackgroundColor="Transparent" HeightRequest="100"/>
</ListView.Footer>
</ListView>
</StackLayout>
<customcontrols:FloatingTextEditor DidFinishWithDone="FloatingTextEditor_DidFinishWithDone" KeyboardDidShow="FloatingTextEditor_KeyboardDidShow" AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds="0,1"></customcontrols:FloatingTextEditor>
</AbsoluteLayout>
</pages:BaseContentPage.MainContent>
</pages:BaseContentPage>
I'm not using the gyroscope and the app is set to Portrait mode only.
Any idea what I'm doing wrong?
Expected layout, and what happens when i hold the Phone:
Layout when phone is placed on a level plane:
I ended up replacing the absolute layout with a grid layout. It works, but I'm still not sure why the absolute layout didn't work
I am facing trouble to implement "Soft Keyboard Input Mode" and fix keyboard overlap issue in Xamarin.Forms iOS app.
The following solutions that I have tried:
Scroll View: Which is not work for me because I am already using one scroll view in my content page so nested scroll view will not work as defined in following article https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/scroll-view.
Xamarin.IQKeyboardManager: Which is solve the overlap issue but hides the top content by taking it up which I am not be able to scroll down.
I have also tried following articles
https://xamgirl.com/adjusting-elements-when-keyboard-shows-in-xamarin-forms/
https://github.com/adamped/SoftInput/blob/master/SoftInput/SoftInput.iOS/Render/KeyboardRender.cs
Also facing another issue without "Soft Keyboard Input Mode" getting blank white space sometime top and bottom while focusing to Entry control that trigger keyboard up and down on multiple clicks.
The following page layout designs I am using in my two pages (Facing issue in 2 pages which has I am already using scroll view)
Page 1:
`<ContentPage.Content>
<StackLayout >
<ScrollView Margin="10,10,10,0">
<StackLayout x:Name="pageContentLayout">
</StackLayout>
</ScrollView>
<AbsoluteLayout HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<StackLayout x:Name="mainEntryLayout"
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1">
<ActivityIndicator x:Name="entryIndicator"
IsVisible="False"
IsRunning="False">
</ActivityIndicator>
<Grid VerticalOptions="EndAndExpand"
HorizontalOptions="EndAndExpand"
x:Name="entryGrid"
BackgroundColor ="{StaticResource Color}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="85*"/>
<ColumnDefinition Width="15*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<custom:CustomEntry CornerRadius="4"
IsCurvedCornersEnabled="True"
BorderColor="{StaticResource Color}"
PlaceholderColor="{StaticResource Color}"
TextColor="{StaticResource Color}"
VerticalOptions="FillAndExpand"
HeightRequest="100"
HorizontalOptions="FillAndExpand"
Grid.Column="0"
FontSize="12"
BackgroundColor ="{StaticResource Color}"
x:Name="commentCustomEntry"
Keyboard="Chat"
Margin="10"/>
<ImageButton VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
Grid.Column="1"
HeightRequest="30"
WidthRequest="30"
x:Name="SendBtn"
BackgroundColor="Transparent"/>
</Grid>
</StackLayout>
<StackLayout x:Name="pageIndicatorLayout"
IsVisible="false"
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1">
<Label x:Name="loadingLabel" TextColor="{StaticResource Color}"/>
<ActivityIndicator IsRunning="true"
Color ="{DynamicResource Color}"/>
</StackLayout>
</AbsoluteLayout>
</StackLayout>
</ContentPage.Content>
`
Page 2:
`
<StackLayout>
<AbsoluteLayout HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<StackLayout x:Name="pageContentLayout"
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1">
<StackLayout x:Name="ImgLayout" ></StackLayout>
<ScrollView>
<StackLayout>
<StackLayout Orientation="Vertical"
HorizontalOptions="FillAndExpand">
<Label Text="{Binding titleLable}"
FontAttributes="Bold"
TextColor="{StaticResource Color}"
Margin="10, 0, 0, 0"
FontSize="14"/>
<Label x:Name="resourceLabel"
TextColor="{StaticResource Color}"
FontSize="11"
Margin="10, 0, 0, 0" />
<Label Text="{Binding sourceLabel}"
TextColor="{StaticResource Color}"
FontSize="11"
FontAttributes="Bold"
Margin="10, 0, 0, 0" />
<Label x:Name="personLabel"
TextColor="{StaticResource Color}"
FontSize="11"
Margin="10, 0, 0, 0" />
<Label FontAttributes="Bold, Italic"
FontSize="12"
Padding="10,10,10,0"
Text="{Binding hightlightLabel}"/>
</StackLayout>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<local:ExtendedWebViewModel x:Name="webContentView"
Grid.Row="0"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"/>
</Grid>
</StackLayout>
</ScrollView>
<Grid Padding="10,0,10,0" RowSpacing="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60*"/>
<ColumnDefinition Width="40*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackLayout Grid.Column="1"
Grid.Row="0"
Grid.RowSpan="2"
Orientation="Horizontal"
HorizontalOptions="EndAndExpand"
VerticalOptions="CenterAndExpand">
<Image Source="{Binding lImg, Converter={StaticResource Converter}}"
HeightRequest="20"
WidthRequest="20">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnLImgTapped"
CommandParameter="{Binding item}"/>
</Image.GestureRecognizers>
</Image>
<Label x:Name="tCount"
VerticalOptions="CenterAndExpand"
Text="{Binding tCount}"
FontSize="12">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="OntCountTapped"
CommandParameter="{Binding item}"/>
</Label.GestureRecognizers>
</Label>
<Image Source="{Binding cImg, Converter={StaticResource Converter}}"
HeightRequest="20"
WidthRequest="20">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnCImgTapped"
CommandParameter="{Binding item}"/>
</Image.GestureRecognizers>
</Image>
<Label Text="{Binding cCount}"
VerticalOptions="CenterAndExpand"
FontSize="12">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="OnCCountTapped"
CommandParameter="{Binding item}"/>
</Label.GestureRecognizers>
</Label>
<Image Source="{Binding SImg, Converter={StaticResource Converter}}"
HeightRequest="20"
WidthRequest="20">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnSImgTapped"
CommandParameter="{Binding item}"/>
</Image.GestureRecognizers>
</Image>
</StackLayout>
</Grid>
<Grid VerticalOptions="EndAndExpand"
HorizontalOptions="EndAndExpand"
x:Name="entryGrid"
BackgroundColor ="{StaticResource Color}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="85*"/>
<ColumnDefinition Width="15*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<custom:CustomEntry CornerRadius="4"
IsCurvedCornersEnabled="True"
BorderColor="{StaticResource Color}"
PlaceholderColor="{StaticResource Color}"
TextColor="{StaticResource CommentEntryValueColor}"
VerticalOptions="FillAndExpand"
HeightRequest="100"
HorizontalOptions="FillAndExpand"
Grid.Column="0"
FontSize="12"
BackgroundColor ="Color"
x:Name="commentCustomEntry"
Keyboard="Chat"
Margin="10"/>
<ImageButton VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"Grid.Column="1"
HeightRequest="30"
WidthRequest="30"
Clicked="OnSendButtonClicked"
x:Name="SendBtn"
BackgroundColor="Transparent"/>
</Grid>
</StackLayout>
<StackLayout x:Name="pageIndicatorLayout"
IsVisible="false"
Padding="12"
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1">
<Label x:Name="loadingLabel" TextColor="{StaticResource Color}"/>
<ActivityIndicator IsRunning="true"
Color ="{DynamicResource Color}"/>
</StackLayout>
</AbsoluteLayout>
</StackLayout>
`
Could you please suggest the better solution?
Thanks
If you are targeting ios only, Remove the scrollview and try this plugin. https://github.com/paulpatarinski/Xamarin.Forms.Plugins/tree/master/KeyboardOverlap
After installing this nuget ,
Add these line in your Appdelegate class after Xamarin.Forms.Init().
KeyboardOverlapRenderer.Init ();
No need for you to do anything other then initialize the plugin. The keyboard will no longer overlap your Controls!!!
I've been trying to get this looking right in Xaml (x.forms) but can't make it work. Any possibly way this can be solved in Xaml without a custom cell renderer?
Here is how it's supposed to look on native iOS:
What I'm getting so far in Xaml:
Here's my Xaml:
<ScrollView>
<StackLayout>
<ActivityIndicator IsRunning="{Binding IsFetching}" />
<ListView ItemsSource="{Binding Events}" Header="2015" Footer="">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Height="55">
<ViewCell.View>
<StackLayout Orientation="Horizontal" Padding="5" BackgroundColor="White">
<StackLayout>
<BoxView WidthRequest="44"
HeightRequest="5"
BackgroundColor="Purple"
/>
<Label Text="AUG" FontSize="12" HeightRequest="13" HorizontalOptions="Center" VerticalOptions="Start" FontAttributes="Bold"/>
<Label Text="31" FontSize="13" VerticalOptions="StartAndExpand" HorizontalOptions="Center" />
</StackLayout>
<StackLayout Orientation="Vertical"
HorizontalOptions="StartAndExpand">
<Label Text="Relay For Life of" FontSize="14" VerticalOptions="End" TextColor="Gray"/>
<Label Text="Hope City" FontSize="16" FontAttributes="Bold" VerticalOptions="StartAndExpand"/>
</StackLayout>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ScrollView>
You can try this with a Grid instead of Stack, also add RowHeight to your ListView
<ListView ... RowHeight="55">
...
<ViewCell Height="55">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="44"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="44"/> <!-- for the checkmark -->
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="5" />
<RowDefinition Height="22" />
<RowDefinition Height="17" />
</Grid.RowDefinitions>
<BoxView Grid.Row="0" WidthRequest="44" HeightRequest="5" BackgroundColor="Purple"/>
<!-- experiment with the vertical alignment to get it right -->
<Label Grid.Row="1" Text="AUG" .../>
<Label Grid.Row="2" Text="31" .../>
</Grid>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="22" />
<RowDefinition Height="22" />
</Grid.RowDefinitions>
<!-- if the vertical alignment doesn't work well add two more rows for top and bottom padding -->
<Label Grid.Row="0" Text="Relay for life" VerticalOptions="End" .../>
<Label Grid.Row="1" Text="Hope city" VerticalOptions="Start" .../>
</Grid>
</Grid>
</ViewCell>
Set HasUnevenRows="True" on the ListView
Silverlight 3;
I have a ValidationSummary in the top row of my grid. When the ValidationSummary appears, it pushes my button row (row 3) off the bottom of the displayable screen.
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="36" />
</Grid.RowDefinitions>
<di:ValidationSummary Grid.Row="0" />
<Grid x:Name="gridOuterContentHolder"
Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="0.68*" />
<RowDefinition Height="5" />
<RowDefinition Height="0.32*" />
</Grid.RowDefinitions>
<!-- elements removed for brevity -->
</Grid>
<StackPanel x:Name="stack"
Grid.Row="2"
Orientation="Horizontal"
HorizontalAlignment="Right">
<Button Content="Delete"
x:Name="btnDelete"
Height="20"
Width="75" />
</StackPanel>
</Grid>
I'm a code monkey not a pixel pusher and can't figure out which combination of Stretch's, Auto's and *'s I need. Any pushers out there that can help??
Thanks,
Mark
I was able to do this by making the validationsummary control a child of scrollview with a maxheight set. This limits the ability of the validationsummary to stretch beyond its parent's maxheight.
Because by default, validationsummary controls use a getparent() to determine the control they are validating, this requires you to manually override the target when the appication innitializes (in vb I do it in the new() routine of my page class.
MyValidationSummary.Target = TheNewGrid
You probably don't want to see the scrollviewer when there are no errors, so set it to Collapsed and in the make it visible only with the validationsummary has errors:
Private Sub MyValidationSummary_LayoutUpdated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyValidationSummary.LayoutUpdated
If MyValidationSummary.HasErrors Then
svMyValidationSummary.Visibility = Windows.Visibility.Visible
Else
svMyValidationSummary.Visibility = Windows.Visibility.Collapsed
End If
End Sub
I can't seem to get this editor to not screw up the xaml, here's a link:
example
<ScrollViewer Visibility="Collapsed" x:Name="svMyValidationSummary" MaxHeight="200" Margin="6" BorderThickness="1">
<dataInput:ValidationSummary FocusControlsOnClick="True" x:Name="MyValidationSummary"></dataInput:ValidationSummary>
</ScrollViewer>
<data:DataGrid Margin="10" AutoGenerateColumns="False" Width="1250" x:Name="TheNewGrid" Height="350">
<data:DataGrid.Columns>
<local:DataGridTemplateColumnBindingText CanUserReorder="False" CanUserResize="False"
HeaderStyle='{StaticResource RowHeaderColumnStyle}' >
<local:DataGridTemplateColumnBindingText.CellEditingTemplate>
<DataTemplate>
<controlsToolkit:DockPanel HorizontalAlignment="Stretch">
<StackPanel controlsToolkit:DockPanel.Dock="Right" Orientation="Horizontal">
<Button ToolTipService.ToolTip="Insert an empty row" Click="btnInsertRow_Click">
<Image Source="add.png"></Image>
</Button>
<Button ToolTipService.ToolTip="Copy row" Click="btnDuplicateRow_Click">
<Image Source="application_double.png"></Image>
</Button>
<Button ToolTipService.ToolTip="Delete row" Click="btnDeleteRow_Click">
<Image Source="delete.png"></Image>
</Button>
</StackPanel>
<Border BorderThickness="1" Background="PowderBlue">
<TextBlock controlsToolkit:DockPanel.Dock="Left" TextAlignment="Center" HorizontalAlignment="Stretch" Text="{Binding SortNumber}"></TextBlock>
</Border>
</controlsToolkit:DockPanel>
</DataTemplate>
</local:DataGridTemplateColumnBindingText.CellEditingTemplate>
</local:DataGridTemplateColumnBindingText>
</data:DataGrid.Columns>
</data:DataGrid>