ScrollViewer Issue with StackPanel in Windows Phone 8 - xaml

I put StackPanel into ScrollViewr, When scrolling to last item it returns back to its old position.
<ScrollViewer Margin="0,0,0,20">
<StackPanel>
//Textblocks and Textboxes ...
</StackPanel>
</ScrollViewer>
After search i found that:
ItemsControl, VirtualizingStackPanel and ScrollViewer height
I changed my code to:
<StackPanel>
//Textblocks and Textboxes ...
</StackPanel>
<ScrollViewer>
<VirtualizingStackPanel />
</ScrollViewer>
I can't set CanContentScroll="True" as i can't find it.
Also make exception:
System.InvalidOperationException: A VirtualizingPanel is not nested in an ItemsControl. VirtualizingPanel must be nested in ItemsControl to get and show items.
What must i do, to enable scrolling without returning back to its old position?
Regards,

After search again ...
I found this Post which solve the problem of Scrolling return to old position when open keyboard.
Scrolling page with keyboard shown
code after updates:
<ScrollViewer Height="500" VerticalAlignment="Top">
<StackPanel Height="700">
//Textblocks and Textboxes ...
</StackPanel>
</ScrollViewer>

Related

Windows 8 Store App Sliding Panel

I am working on a Windows 8 Store App. I want to use sliding panel for my application such as facebook mobile application leftside menu or rightside friends list. What am i want to do ? When i click to button panel should open left 0 to right side about 300px but i didn't find any solution for this. Can you help me for this ? Thx inadvance.
I SOLVED
Actually, I don't want to work with scrollview i want to show a setting pane. I solved my problem with using settingflyout. So, you can use basicly in your project. Add new item >> add settingflyout. But thx for your answer.
<ScrollViewer
x:Name="HorizontalScrollViewer"
VerticalScrollBarVisibility="Auto"
VerticalScrollMode="Disabled"
ZoomMode="Disabled"
HorizontalScrollBarVisibility="Auto"
HorizontalScrollMode="Auto"
HorizontalSnapPointsAlignment="Near"
HorizontalSnapPointsType="Mandatory">
<StackPanel
Orientation="Horizontal">
<Grid
x:Name="LeftPanel">
...
</Grid>
<Grid
x:Name="CenterPanel">
<ListView .../>
</Grid>
<Grid
x:Name="RightPanel">
...
</Grid>
</StackPanel>
</ScrollViewer>

Empty collection bound to LongListSelector cause incorrect view of page

I have Windows Phone 8 page which has a number of controls on it, some of them are LongListSelector controls. If all collections have content everything is displayed correctly.
But if any of the collections bound to the lists are empty all controls below them on the page disappear, i.e. the page looks to be truncated as lots of things are missing.
If I add code to make sure to add at least on item to each collection the page display correctly.
The databinding is done using C#, as shown below.
XAML
<phone:LongListSelector Grid.Row="3" x:Name="PicturesGrid">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Image Source="{Binding Filename}" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
C#
PicturesGrid.ItemsSource = App.ViewModel.SelectedBird.Pictures;
Update: I have noticed that there is a scrollbar present, but however much I scroll I never get down to the bottom.

ListViewItems Animation no longer working

I have a ListView in my XAML that contains multiple thumbnail images, after selecting some pictures with a Picker. My issue is that, I have changed the item panel template like below, and now the animations for adding of deleting an item, simply won't work. The items just pop in or disappear...
Here's how my ListView look like :
<ListView x:Name="ThumbnailsListView"
ItemTemplate="{StaticResource ImageTemplate}"
ItemsSource="{Binding Images}"
SelectionMode="Multiple"
SelectionChanged="OnThumbnailsSelectionChanged">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" >
<WrapGrid.ChildrenTransitions>
<TransitionCollection>
<ContentThemeTransition/>
</TransitionCollection>
</WrapGrid.ChildrenTransitions>
</WrapGrid>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
What could be wrong? If I cut down the part with the ItemsPanelTemplate the animations are OK but the visual effect is not the one desired.
I wish that items would fill the panel horizontally and then proceed to the next line.
You need to get other transitions in your ChildrenTransitions collection, like AddDeleteThemeTransition.

Xaml, How to bind a list of buttons over an image in different coordination

For a windows 8 Apps, i need to put a list of buttons over an image. Each button has CoordinateX and CoordinateY properties. I use a gridView to bind to the list of buttons.
I need to have the result as below:
Here is my code:
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" >
<Canvas>
<Image Source="ms-appx:///Assets/red.png" Stretch="None" ></Image>
<GridView ItemsSource="{Binding Buttons}"
SelectionMode="None" IsSwipeEnabled="false" IsItemClickEnabled="True" ItemClick="Button" Padding="0">
<GridView.ItemTemplate>
<DataTemplate>
<Button Width="194" Height="51" Background="Gray" Canvas.Left="{Binding CoordinateX}" Canvas.Top="{Binding CoordinateY}"></Button>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Canvas>
</Grid>
But this is what i get after running the app:
Ites Likely that at runtime before the X and Y co-ordinates can be set for the items within the GridView, the GridView itself has its properties applied.
Since
1) the GridView is intended to be used for oganization control
and
2) you havent forced the Grid to fill the view space
what you're left with is a GridView that acts as it wishes and limits the ability of its items to conform to your style, should the style attempt to force the items collection to live outside the bounds of the control.
You could try to set the GridView's Horizontal Alignment property but even if it happens to work, its probably a better bet to use a less organized content control like the more basic ItemsPresenter.
Which ever control you end up using... make sure to check for /set the HorizontalContentAlignment & VerticalContentAlignment properties if they exist.

Windows8 ListView LineHeight

I have added a ListView to a Metro Style Blank App. Added to the ListView are 3 Strings. I want to change the LineHeight , but cannot find a property. Below is my xaml code.
<Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
<ListView HorizontalAlignment="Left" Height="277.167" Margin="235.51,161,0,0" VerticalAlignment="Top" Width="100" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto">
<ListView.RenderTransform>
<CompositeTransform SkewX="-0.338" TranslateX="-0.327"/>
</ListView.RenderTransform>
<x:String>test 1</x:String>
<x:String>Test2</x:String>
<x:String>Test3</x:String>
</ListView>
</Grid>
How do I decrease, increase the line height of the strings in the ListView box? I want to decrease the space between the lines.
Thanks
Try editing a ItemContainerTemplate and then play with the properties available like margin and padding.
See my answer here :
WPF ComboBox customization in windows8
let me know in case you need any help.