Windows Phone 8 Continue parent scrolling - windows-phone-8

I have a Windows Phone 8 application (please note that it's not 8.1) and I have the following struggle.
I have a page containing a StackPanel. Within the StackPanel there are several objects like buttons, textboxes and a LongListSelector.
The LongListSelector is bound to an ItemsSource. Because it can contain a lot of items I had to set the MaxHeight (otherwise it exceeds the limit of 2000px of vertical screen space)
However when scrolling the page down I stumble upon the LongListSelector. I can than scroll the LongListSelector too, which is fine. But when I scroll to the end of the LongListSelector it won't 'snap' to the StackPanel so it just leaves the page there and doesn't continue with scrolling to StackPanel.
A short code example:
<StackPanel>
<Button />
<TextBlock />
<TextBox />
<Button />
<LongListSelector>
This contains a bunch of items
<LongListSelector/>
<TextBox />
</StackPanel>
So what happends is.. I can scroll the complete page to the LongListSelector. I can scroll the LongListSelector. But when I'm at the end of the LongListSelector.. It wont continu scrolling the page.
So I never see the last TextBox (in this example that is)
I've also tried replacing the LongListSelector with a ListBox but that doesn't make any difference.
Hope that someone can help me out here.

From your Question what I understood is that the total height by summing up your UI Elements is more than the Page Height. If you put a ScrollViewer Tag at the start and End of StackPanel. It will work just fine. In ListBox and LongListSelector it is implied.
<ScrollViewer>
<StackPanel>
<Button />
<TextBlock />
<TextBox />
<Button />
<LongListSelector>
This contains a bunch of items
<LongListSelector/>
<TextBox />
</StackPanel>
</ScrollViewer>

Related

Bring Label to the front in a Xamarin Grid

Im trying to have a Label on top of the Map but when I put them inside a Grid like this
<Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="Red">
<Frame BackgroundColor="{StaticResource Color2}" Margin="0">
<Label TextColor="{StaticResource Color5}" FontSize="60" FontAttributes="Bold" x:Name="TituloNombre" HorizontalOptions="CenterAndExpand"></Label>
</Frame>
<local:CustomMap IsShowingUser="True" HasScrollEnabled="True" HasZoomEnabled="True" MapClicked="mapaXaml_MapClicked" x:Name="mapaXaml" Opacity="0.5"/>
</Grid>
The map covers the Label and the only way I can see it is by changing the opacity of the map.
Items within the Grid will be rendered back to front. Ie, things that are listed first will be behind things that are later in the same container
Reorder uour Grid so the Label is after the Map

Save selected text block on another page in Windows Phone 8

I have added following text blocks as part of MainPage.xaml:
<ScrollViewer>
<StackPanel>
<TextBlock x:Name="Test1" TextWrapping="NoWrap" TextTrimming="WordEllipsis" Height="89" Width="220">
<Run>This is test text block1</Run>
</TextBlock>
<TextBlock x:Name="Test2" TextWrapping="NoWrap" TextTrimming="WordEllipsis" Height="89" Width="220">
<Run>This is test text block2</Run>
</TextBlock>
<TextBlock x:Name="Test3" TextWrapping="NoWrap" TextTrimming="WordEllipsis" Height="89" Width="220">
<Run>This is test text block3</Run>
</TextBlock>
</StackPanel>
</ScrollViewer>
I am trying to develop logic so that when I click the text block, the content of the text block can be saved as a link in on another page. The user should be able to click the link saved on the other page and jump to the relevant text block directly. In a way the saved text block will work as a bookmark to the associated text block. I would also like to extend the logic to remove the saved text block.
I am able to add/remove tapped textblock from textblock tbk1 to textblock tbk2 on the same page. This is the code I am using on Tap event:
private void listitemselected(object sender, System.Windows.Input.GestureEventArgs e)
{
{
foreach (var item in tbk1.SelectedItems)
{
tbk2.Items.Add(item);
}
}
}
However, how can I add the tapped text block on another page?
Can someone please point me to any reference material or guide me to understand the right approach to achieve this goal?
Thanks,
Aiseduk
you can use application storage to save your data
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh700361.aspx try this link it will solve your problem

How to reuse a flyout menu on WinRT

I have a project where I've lot a few diferent listview/gridviews itemstemplate.
yet all share the same flyout menu, something like this
<FlyoutBase.AttachedFlyout >
<MenuFlyout >
<MenuFlyoutItem x:Uid="lbl_action_sheet_title_add_to_playlist" Text="$add to playlist" />
<MenuFlyoutItem x:Uid="lbl_action_sheet_share" Text="$share" />
</MenuFlyout>
</FlyoutBase.AttachedFlyout>
And I want to reuse it not copy paste it to N templates
Any ideas?
You could use an attached behavior to attach the menu from a DataTemplate resource.

Horizontal stretching - group header ListView

So... Any bright ideas how we can enable Horizontal content stretching on the GroupHeader template of a Grouped ListView in Win RT - phone?
I'm all ears!
I've added a demo application so you can try it out - please do before posting your answer!
Code can be found here https://github.com/Depechie/ListView-HorizontalStretch-RT81
I added 2 pages, MainPage has the problem of not having Horizontal stretching.
MainPage2 has a fix for Horizontal stretching, but because of that fix, the JumpList ( zoomed out view ) is not working anymore.
You can navigate from MainPage to MainPage2 through the appbar button.
Here the 2 visuals
Your fix is overly complicated and deprecated. What you need for your group header style is as simple as the following:
<Style x:Key="FixedHeaderContainerStyle"
TargetType="ListViewBaseHeaderItem">
<Setter Property="HorizontalContentAlignment"
Value="Stretch" />
</Style>
And apply it to your ListView like so (old ContainerStyle is deprecated and replaced with HeaderContainerStyle):
<GroupStyle HidesIfEmpty="True"
HeaderTemplate="{StaticResource AddrBookGroupHeaderTemplate}"
HeaderContainerStyle="{StaticResource FixedHeaderContainerStyle}" />
BUT the header fix wasn't the reason why your ZoomedOutView stopped working. The issue is because you added the following to MainPage2:
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
VirtualizingStackPanel breaks this and the new and improved panel (that includes virtualization is ItemsStackPanel, which is also the default now so omit this altogether.
If I understand the problem, add Width="{Binding ElementName=LayoutRoot, Path=ActualWidth}" to your MobileAppsGroupHeaderBorder on MainPage. That'll render as full width like MainPage2 but the jump list functionality is maintained as normal.

How to keep a page open in the background when starting a new page in windows phone?

I have one simple application that have few pages.
On first page I have addMob, and that is working fine.
On that page I have a button for the contact page. When I open the contact page and return to the main page, addMob refreshes.
I do not want to do that. How can I put that first page in background without starting it again when user the returns from the contact page?
No. By design, in windows phone, you can have only one page active (visible) at a time. Ad controls will unload and refresh automatically when you navigate between pages. We have no control over this behaviour.
In my experience, I don't think we have to worry about Ads refreshing if navigation is fairly infrequent. As long as you expect the user to stay on a page for about 20 to 30 seconds on average, I would suggest not to worry about refresh. In fact, (again, in my personal experience) I receive more clicks with this implementation than having one static Ad control refreshing at a fixed interval.
But if you still have to avoid Ad refresh, here are couple of workarounds.
Option 1: Embed the "contact page" as a ContentControl/UserControl inside the Main page. Show and hide the contact control as required. Below is a very basic XAML design to demonstrate this.
<Grid>
<Grid.RowDefinition>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinition>
<AdControl Grid.Row="0" Height="80" />
<Grid Name="MainPage" Grid.Row="1">
<!-- Main page content -->
</Grid>
<view:ContactPage Name="Contacts" Grid.Row="1" Visibility="Collapsed">
<!-- Contact page content -->
</view:ContactPage>
</Grid>
Also, remember to handle BackButtonPress if you are going with this approach. The user would expect pressing back button, when the content page is visible, to take them back to Main page.
Option 2: If your application design would allow, use a Panaroma or Pivot control to show Main and Contact pages. Sample below,
<Grid>
<Grid.RowDefinition>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinition>
<AdControl Grid.Row="0" Height="80" />
<controls:Pivot Grid.Row="1">
<controls:PivotItem Header="Main page">
<!-- Main page content -->
</controls:PivotItem>
<controls:PivotItem Header="Contacts">
<!-- Contact page content -->
</controls:PivotItem>
</controls:Pivot>
</Grid>