Question How can I make a Grid with ItemsWrapGrid layout in C #?
Context
- UWP
- Visual studio 2015
- Windows 10
- FROM#
Background
I know how to do this in XAML. After creating a new UWP application in Visual Studio 2015 XAML:
<Page x:Class="WrapGridTest001.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:WrapGridTest001" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" MinWidth="10" MinHeight="10" > <Grid x:Name="thisGrid"> <GridView x:Name="thisGridView" IsItemClickEnabled="True"> <GridView.ItemsPanel> <ItemsPanelTemplate> <ItemsWrapGrid x:Name="thisItemsWrapGrid" Orientation="Horizontal" MaximumRowsOrColumns="5" /> </ItemsPanelTemplate> </GridView.ItemsPanel> <TextBlock Text="#1"/> <TextBlock Text="#2"/> <TextBlock Text="#3"/> </GridView> </Grid> </Page>
To do this programmatically, I took it from XAML:
<Page x:Class="WrapGridTest001.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:WrapGridTest001" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" MinWidth="10" MinHeight="10" > </Page>
and tried to play it in the Page constructor:
public MainPage() { this.InitializeComponent();
What additional code do I need to add to install ItemsWrapGrid in C #, how was it installed in XAML? C # code is currently generating ItemsWrapGrid , but ItemsWrapGrid is not actually set up anywhere, since every attempt to use it so far has led to some error.
source share