Windows Phone 8.1 displaying Azure data on listview - xaml

I'm facing some issues with displaying data on a listview in my WindowsApp 8.1 mobile. There is a table in my Azure Mobile Service called SugarControler which is the same name for a class that handles the data. which stores some data and has a column called "Level". When I'm trying to display data from that column in my app, I don't get data from that column, but instead every record displayed in the ListView is MyApp.Controlers.SugarControler. What am I missing here?
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
...
<ListView Name="ListItems" Margin="0,9.5,-0.167,10" Grid.Row="4">
<ListView.Resources>
<DataTemplate x:Name="cell">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Level}"/>
</StackPanel>
</DataTemplate>
</ListView.Resources>
</ListView>
</Grid>
From the backend site everything seems to be ok, as I can add a new data into the database from the UI and it is displayed properly in the Azure database.

Related

UWP Xaml Binding properties to an other page in a splitview

i need a little hand on this please,
Context : Windows 10 UWP Development, C#, Visual Studio 2017
I don't understand why I can pass INotify properties in my code, but i can not in the GEDContenuPage page view, that I want to add in the left pane of my SplitView.
<SplitView Grid.Row="1"
IsPaneOpen="{Binding IsGEDOpen}"
DisplayMode="Inline"
OpenPaneLength="{Binding GEDPaneWidth}">
<SplitView.Pane>
<Grid>
<v:GEDContenuPage Visibility="{Binding IsGEDOpen, Converter={StaticResource BoolToVisibilityConverter}}" />
</Grid>
</SplitView.Pane>
<ScrollViewer >
<Grid x:Name="mainGridData" />
</ScrollViewer>
</SplitView>
IsPaneOpen="{Binding IsGEDOpen}" will works and do its job (open or close left pane)
BoolToVisibilityConverter is in app.xaml and works well (tested somewhere else)
I have also created a DependencyPropertyin my page control :
<v:GEDContenuPage
Visibility="{Binding IsGEDOpen, Converter={StaticResource BoolToVisibilityConverter}}"
ext:GEDContenuPageExtension.ContenuId="2446"
/>
Same thing here, 2446 will works well, This will open my left pane with the right content.
But I i try to replace it with a Binding :
ext:GEDContenuPageExtension.ContenuId="{Binding GedContenuId}
It won't work.
I guess this is end of the week, and the only thing I need is a fresh beer to put things right in my mind...
For your information, the left pane will receive other page than GEDContenuPage. This is why I need a visibility property for each page.
Thanks for help,
OK this was a datacontext issue, this done the trick
<Grid Name="parentGrid">
<v:GEDContenuPage Visibility="{Binding DataContext.IsGEDOpen, Converter={StaticResource BoolToVisibilityConverter}, ElementName=parentGrid}" />

HubControl: Different files for each hub section on windows phone 8.1

I cannot find any information about how to structure the hubControl a little bit better. All the examples I can find put all the information in one xaml file. Am I missing something? I don't think that this gives you an easily maintainable code. The hub template creates the following code (stopping after the first section to abbreviate but there are four more to come in the sample code):
<Grid x:Name="LayoutRoot">
<Hub x:Name="Hub" x:Uid="Hub" Header="application name" Background="{ThemeResource HubBackgroundImageBrush}">
<HubSection x:Uid="HubSection1" Header="SECTION 1" DataContext="{Binding Groups}" HeaderTemplate="{ThemeResource HubSectionHeaderTemplate}">
<DataTemplate>
<ListView
ItemsSource="{Binding}"
IsItemClickEnabled="True"
ItemClick="GroupSection_ItemClick"
ContinuumNavigationTransitionInfo.ExitElementContainer="True">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,27.5">
<TextBlock Text="{Binding Title}" Style="{ThemeResource ListViewItemTextBlockStyle}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</HubSection>
How is it possible to have each section in a different xaml file?
Or are there other ways to get a better code structure?
I did something like this with the pivot control by adding the pivot items in code but the hub control does not have a content property and messing around with content templates seems a little bit too ugly. Does anyone have an idea? Thanks in advance.
Although I am still struggeling with passing the data context/ viewModel in some cases I guess the simple solution is to just create a new file (user control or page) and use something like
<HubSection Header="About">
<DataTemplate>
<local:AboutPage />
</DataTemplate>
</HubSection>
Thanks to everybody who had a look!
I think what you're looking for is a DataTemplateSelector. This allows you to write a custom mapping from instance to template in code.

Problems showing a web 3Dmodel viewer in the webBrowser control XAML

I am trying to show a url from Sketchfab and I can´t get the desired results. I need to show a page like this.
https://sketchfab.com/models/dGUrytaktlDeNudCEGKk31oTJY/embed?autospin=0.3&autostart=1&ui_infos=0
If you go there you can see that the model starts to spin automatically but if I put this Url in the source property of my WebBrowser control it shows the model but I doesn´t spin. The code that I am using is this:
<phone:PanoramaItem Header="{Binding Source={StaticResource LocalizedStrings}, Path=LocalizedResources.MainPagePanoramaItemViewTitle}" Orientation="Horizontal">
<Grid>
<phone:WebBrowser x:Name="WebBrowserViewer" Background="Black" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="450"
Source="https://sketchfab.com/models/dGUrytaktlDeNudCEGKk31oTJY/embed?autospin=0.3&autostart=1&ui_infos=0"
IsScriptEnabled="True" HorizontalContentAlignment="Stretch"/>
</Grid>
</phone:PanoramaItem>
Is posible reproduce this "autospin" and adjust de viewer to the WebBrowser control ?
Thanks a lot

Windows Phone 8 more Items in row as template

I'm new in Windows Phone 8 development and I want to create a page with any number of items sorted in two columns as this great image shows.
I was trying to use LongListSelector, but i was able to create only one column. So what control should I use to create such a template?
install windows phone toolkit
add this code in your xaml in phone:PhoneApplicationPage
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
this is your list code
<ListBox x:Name="pictureListBox" Margin="10,101,10,10" ItemsSource="{Binding}" SelectionChanged="pictureListBox_SelectionChanged_1">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" >
<Image x:Name="Image" Source="{Binding Thumb}" Stretch="Uniform" Width="200" Height="200" Margin="10"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Take a look at the Toolkit for Windows Phone and look at the WrapPanel, this will solve your problem :-)

How to reuse XAML code blocks without binding?

I have this XAML code block:
<StackPanel Orientation="Horizontal">
<TextBlock Text="Hello " />
<TextBlock Text="World" />
</StackPanel>
I would like to define this block (for example in /Common/CustomStyles.xaml) to include it on different XAML pages. How does it work?
I do not need a DataTemplate or something similar because the text is static.
You could put it in a user control and re-use it that way. If it's just the text you are interested in then you could use a resource file - this would update the textbox on any screen as long as it had the right uid.