Placing an element exactly below another one on WP8? - xaml

I would like to place a GRID element just below another GRID element using XAML just like Android's layout below. How can it be done, if possible?

Is this all you're looking for?
<StackPanel>
<Grid/>
<Grid/>
</StackPanel>

Related

How do I make PivotItems in Pivot wrap around like a WrapPanel?

I would like to have the PivotItems in my Pivot to wrap around when the items exceed the App width much like a WrapPanel instead of the default scrolling. I tried setting up the Pivot.ItemTemplate as shown below but that didnt work. Thanks in advance.
<Pivot.ItemTemplate>
<DataTemplate>
<controls:WrapPanel />
</DataTemplate>
</Pivot.ItemTemplate>
There are many design mechanisms inside the HeaderTemplate of NavigationView and Pivot. It is very difficult to change it. But we could achieve a similar effect through layout. You could add a wrapPanel, then add controls inside the panel and use Frame to navigate to another page. As follows:
<StackPanel >
<wrap:WrapPanel x:Name="Itemgrid" Orientation="Horizontal" >
//add your control to show header
</wrap:WrapPanel >
<Frame x:Name="ContentFrame"/>
</StackPanel>

ItemsControl StatusChanged equivalent in UWP

We were able to understand if ItemsControl finished it's rendering by checking Status within StatusChanged event in WPF.
How can I make sure that ItemsControl finished rendering in UWP? I want to make sure that rendering is completed and access some elements using ContainerFromItem.
I have custom dragging logic using events like ManipulationDelta. After rendering, I want to get the ContentPresenter's position based on it's parent UIElement and then use that position to draw some stuff using Win2D. I need item's position, so I need the container, so I need to make sure containers are rendered in the first place, and it goes like that.
To use ItemsControl in UWP, you also need to know about the UI virtualization. The ItemsControl uses UI virtualization. It means that not all items will be rendered at the same time, instead only the viewable area.
You could try the following code:
<ItemsControl x:Name="item">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Loaded="Grid_Loaded">
<TextBlock Text="{Binding}"></TextBlock>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
I registered the Loaded event for the 'Grid' which is included in every item.

How to manipulate items in C#

I'm making a Windows Store App using C# and XAML. How can I manipulate one single item in a GridView or a ListView?
According to certain logical conditions, I need to load or not the item in these containers. I have already tried using the property Visibility.Collapsed and Visibility.Visible of the item, but this just hides or shows the item and it is still loaded in the GridView/ListView, and is selectable.
Thanks for your help.
I reckon you meant to hide your GridViewItem without keeping space in view.
You just need to replace GridView's ItemsPanel with StackPanel or VirtualizingStackPanel.
<GridView>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>

WinRT Bindable Highlight TextBlock control

I'm developing WinRT / windows store app.
Is there any way how i could highlight certain text in TextBlock?
something like that:
<controls:TextBlockHighlight Text="{Binding Text}" HighlightText="{Binding HighlightText}" />
I managed to get required output with
<TextBlock>
<TextBlock.Text>
<Run>......</Run>
</TextBlock.Text>
</Textblock>
But i need that control to be bindable, and i don't how to make it like that..
Filip,
Many thanks for addition in framework.
Highlight textblock behavior is now available in http://winrtxamltoolkit.codeplex.com/
Regards

Referencing an item in a VirtualizingStackPanel

I'm playing with the "Grid Application," which is a C++ Metro app template provided by VS11. The main display is a collection of items displayed in a VirtualizingStackPanel:
<ScrollViewer x:name="itemGridScrollViewer">
<GridView x:name="itemGridView">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
</ScrollViewer>
The actual items are displayed using the Standard250x250ItemTemplate data template defined in StandardStyles.xaml. One of the display elements of this is a graphic.
I'm trying to understand how to reference a specific item so that I can change the graphic at runtime. The ScrollViewer and the GridView have objects associated with them, so I can get to those, but I don't see how to get from there to the individual items.
All this stuff is completely new to me, so be gentle. :)
In general it's not a good idea to dig down into individual templated items in an ItemsControl because not only is it a pain, but that ItemTemplate can regenerate at different times (paging during virtualization, source collection updates, etc) and you'll be left holding an outdated UIElement that's no longer being displayed.
A better approach is to pull the data you need into the item data and in the ItemTemplate use Data Binding to make whatever changes you need to differentiate the UI. One option is to use an IValueConverter to get a different image depending on some state in the item data:
<GridView>
<GridView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Path=DataState, Converter={StaticResource MyStateToImageConverter}}"/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
Here I'm assuming that the converter code has been written and an instance of the converter has already been declared as a resource (see here). You could alternatively do a direct Binding to a property on each item's data that specifies its image and skip the converter part.