When compiling on mobile, an empty line appears that is not in the code. Everything is fine in the studio in the designer, but on the phone everything is different. Where could the error be?
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<Grid Row="0" ColumnSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid Column="0">
<SearchBar x:Name="SearchNickname"
BackgroundColor="{Binding BackColor}"
CancelButtonColor="{Binding TextColor}"
PlaceholderColor="{Binding TextColor}"
TextColor="{Binding TextColor}"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center"
Placeholder="Введите свой ник"
SearchCommand="{Binding SearchCmd}"
Text="{Binding SearchText, Mode=TwoWay, UpdateSourceEventName=TextChanged}"
MaxLength="100"/>
</Grid>
<Grid Column="1" BackgroundColor="{Binding BackColor}">
<Button ImageSource="https://assets.laut.fm/f69a3423e545055c32430e0a77ebe148?t=_120x120"
BackgroundColor="{Binding BackColor}"
Command="{Binding SettingsCmd}"/>
</Grid>
</Grid>
Where does this strip come from? enter image description here
Image in the designer studio enter image description here
That strip along the top is the Header/Navigation Bar, which you get by default in Xamarin Forms Pages. You can modify it or suppress it.
Related
I would like to know if it is possible to collapse a row in a grid ?
I already collapsed the controls inside my row (using Visibility = "Collapsed" + Height = "Auto").
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Content="Test 1"/>
<ProgressBar Grid.Column="1" Value="90"/>
<Label Content="Test 2" Grid.Row="1" Visibility="Collapsed"/>
<ProgressBar Grid.Column="1" Grid.Row="1" Value="50" Visibility="Collapsed"/>
<Label Content="Test 3" Grid.Row="2"/>
<ProgressBar Grid.Column="1" Grid.Row="2" Value="20"/>
</Grid>
But I would like to collapse all the row, whitout doing it for each control in the row, like that :
<RowDefinition Height="Auto" Visibility="Collapsed"/>
Is it possible ? Or should I use something other than a grid ?
Thanks.
I am working on Windows Phone 8.1 app (Windows Runtime)and I have created a page with the following layout :
<Grid Grid.Row="1" Margin="0, 10, 0, 5" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<maps:MapControl x:Name="LocationMap" Grid.Row="0" Height="220"
MapServiceToken="..."/>
<Hub Grid.Row="1" Margin="0, 25, 0, 0">
<HubSection Header="ABOUT" x:Name="AboutHubSection">
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="ShortDescriptionPanel" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" local:TextBlockExtension.FormattedText="{Binding ShortDescription}" FontSize="16" TextWrapping="Wrap"/>
<TextBlock Grid.Row="1" Text="Show more" Visibility="{Binding IsDescriptionTooLong, Converter={StaticResource BoolToVisibilityConverter}}" FontSize="16" Foreground="{StaticResource PhoneAccentBrush}" Tapped="OnShowMoreTapped"/>
</Grid>
<Grid x:Name="FullDescriptionPanel" Grid.Row="1"
Visibility="Collapsed">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding FullDescription}" FontSize="16" TextWrapping="Wrap"/>
<TextBlock Grid.Row="1" Text="Show less" Visibility="Visible" FontSize="16" Foreground="{StaticResource PhoneAccentBrush}" Tapped="OnShowLessTapped"/>
</Grid>
</Grid>
</DataTemplate>
</HubSection>
<HubSection Header="RSVP" x:Name="RsvpHubSection" Margin="0, 0, 0, 50">
<DataTemplate>
<ScrollViewer>
<TextBlock FontSize="16" TextWrapping="Wrap"
Text="{Binding RSVP}"/>
</ScrollViewer>
</DataTemplate>
</HubSection>
<HubSection Header="Statistics" x:Name="StatisticsHubSection" Margin="0, 0, 0, 50">
<DataTemplate>
<ScrollViewer>
<TextBlock FontSize="16" TextWrapping="Wrap"
Text="{Binding Stats}"/>
</ScrollViewer>
</DataTemplate>
</HubSection>
</Hub>
</Grid>
</Grid>
So the content of the page consists of a map control which takes 220 units of Height and the rest should be a Hub with three sections. The HubSections should have their content available for VerticalScrolling if it is the case.
In my particular case, the AboutHubSection should have its content vertically scrollable. The two panels (Short and Full Descriptions) are displayed/hidden one at a time to simulate a "Show more" link which expands the initial short description with a full description of the item. Unfortunately, when the full description is shown, the area does not become scrollable. The textblock that might contain scrollable content is
<TextBlock Grid.Row="0" Text="{Binding FullDescription}" FontSize="16" TextWrapping="Wrap"/>
in the FullDescriptionPanel Grid. I've tried to wrap with a scrollviewer and it didn't work and I'm unsure of what else to try.
Any ideas? Thanks in advance.
You need to set a height limit for your rows.
In your first grid, you should set the second row to Height="*" so your hub control will not be able to expand indefinitively. Since you have used Auto for the two rows, they will each take as much space as needed to fit their content. Using star for the second row will force it to no be bigger than the remaining space.
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
You will have then to do the same for your "full description" view to restrict the space for the long text.
<Grid x:Name="FullDescriptionPanel" Grid.Row="1" Visibility="Collapsed">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0">
<TextBlock Text="{Binding FullDescription}" FontSize="16" TextWrapping="Wrap"/>
</ScrollViewer>
<TextBlock Grid.Row="1" Text="Show less" Visibility="Visible" FontSize="16" Foreground="{StaticResource PhoneAccentBrush}" Tapped="OnShowLessTapped"/>
</Grid>
I have the following XAML:
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<PasswordBox HorizontalAlignment="Center" Grid.Row="0" Margin="12" Width="260" Height="32" PlaceholderText="Confirm Password" BorderBrush="#FF755CB0" BorderThickness="1" Opacity="0.9" x:Name="ConfirmPassword"/>
<Button Content="Sign-Up" HorizontalAlignment="Center" Margin="12" Grid.Row="1" Width="260" Height="50" Background="#FF235085" BorderBrush="#FF6749AC" BorderThickness="1" Foreground="White" Opacity="0.9" RequestedTheme="Light" Click="Register_Click"/>
</Grid>
Right now the grid is at the center of the screen, I wabt it to be a little bit higher, I can do it with margin, but I don't want any propery with pixel in my page. Is there any other wahy to do it?
Thanks.
The easiest way to get your grid slightly above the centre without using Margins would be to put it in another Grid.
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="1.2*"/>
</Grid.RowDefinitions>
<Grid HorizontalAlignment="Center" VerticalAlignment="Top" Grid.Row="1" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<PasswordBox HorizontalAlignment="Center" Grid.Row="0" Margin="12" Width="260" Height="32" PlaceholderText="Confirm Password" BorderBrush="#FF755CB0" BorderThickness="1" Opacity="0.9" x:Name="ConfirmPassword"/>
<Button Content="Sign-Up" HorizontalAlignment="Center" Margin="12" Grid.Row="1" Width="260" Height="50" Background="#FF235085" BorderBrush="#FF6749AC" BorderThickness="1" Foreground="White" Opacity="0.9" RequestedTheme="Light" Click="Register_Click"/>
</Grid>
</Grid>
Note the second RowDefinition
<RowDefinition Height="1.2*"/>
This means the second row will take slightly more of the available space than the first row and you can adjust to meet your needs.
I'd like to have a hyperlink and a textblocks on the same line, however both controls act somewhat different. The hyperlink is just a few pixels more to the right, like there is a margin but it's not, is it? Just look at this piece of code:
<UserControl x:Class="SilverlightApplication7.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="2" Text="Umsatzsteuerart: " />
<TextBlock Grid.Row="2" Grid.Column="1" Text="Test" />
<TextBlock Grid.Row="3" Grid.Column="0" Text="Hersteller:" />
<HyperlinkButton Grid.Row="3" Grid.Column="1" Content="Test" />
<TextBlock Grid.Row="4" Grid.Column="0" Text="Umsatzsteuerart:" />
<TextBlock Grid.Row="4" Grid.Column="1" Text="Test" />
</Grid>
</UserControl>
Shouldn't all three ui-controls be aligned to the same line? Is there a solution for this problem? HorizontalAlignment doesn't effect anything...
Found the solution myself:
Setting the padding of the HyperlinkButton will align the hyperlink correctly.
I do not understand why textbox is not in the label extension.
What did I do wrong?
This is the code:
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Label>Text here:</Label>
<TextBox></TextBox>
</StackPanel>
</Grid>