Banner not shown - windows-phone-7.1

I started to use advertising control, but I'm going crazy trying to let it work.
I copied PivotPage.xaml from Microsoft Ad Control Sample and made it the starting page in my app, but ad control is not shown (I'm not able to see banner); if I try to run Microsoft app, banner is shown.
So I registered my app on pubCenter and I got an appId and a unitId and tried to use them in my app, but the result is the same: no banner!!
If I try to use my ids in Microsoft app, test banner is shown.
Why using Microsoft example I'm able to see banner and using same page in my app I can't?
Why using my ids, Microsoft app does not show correct banner?
Here is XAML
<!--Pivot Control-->
<controls:Pivot Grid.Row="0" Title="Ad Control Sample">
<!--Pivot item one-->
<controls:PivotItem Header="piv 1">
</controls:PivotItem>
<!--Pivot item two-->
<controls:PivotItem Header="piv 2">
</controls:PivotItem>
<!--Pivot item three-->
<controls:PivotItem Header="piv 3">
</controls:PivotItem>
</controls:Pivot>
<StackPanel Grid.Row="1" VerticalAlignment="Bottom" >
<TextBlock Text="This is the same ad."
TextWrapping="Wrap"
HorizontalAlignment="Stretch"
TextAlignment="Center" />
<my:AdControl Name="adControl1"
ApplicationId="test_client"
AdUnitId="Image480_80"
HorizontalAlignment="Center"
Width="480" Height="80" />
</StackPanel>

I finally managed to solve my problem and I want to share solution.
I add an event handler for ErrorOccurred on ad control and reading Microsoft.Advertising.AdErrorEventArgs e I realized that my manifest (WMAppManifest.xml) was missing
<Capability Name="ID_CAP_IDENTITY_USER" />
<Capability Name="ID_CAP_MEDIALIB" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />

Related

Xamarin IOS Shell Itemtemplate FlyoutIcon FontAwesome

I have an Xamarin Shell App. I pulled the code straight from MSDN for the Shell Itemtemplate and it works fine an Android but on IOS the FlyoutIcon is not appearing. I have a feeling it has to do with the fact that I am using FontAwesome for Icons. However I have yet to run across any documentation explaining why there would be an issue with IOS. The icons work perfectly everywehre else in the app. Below is the code for the shell item
<!-- ItemTemplate is for ShellItems as displayed in a Flyout-->
<Shell.ItemTemplate>
<DataTemplate>
<ContentView BackgroundColor="Transparent">
<Grid ColumnDefinitions="0.2*,0.8*" Margin="10">
<Image Source="{Binding FlyoutIcon}"
Margin="5"
HeightRequest="20" />
<Label Grid.Column="1"
Text="{Binding Title}"
TextColor="LightSlateGray"
FontAttributes="Bold"
VerticalTextAlignment="Center" />
</Grid>
</ContentView>
</DataTemplate>
</Shell.ItemTemplate>

Scrolling in Xamarin Forms SfListView causes NullReferenceException in iOS Main function

I just had a very weird issue in my app.
I was adding Syncfusion's SfListView to some pages in my app and for some reason, if the first thing I do when a page that uses the SfListView loads is scroll the ListView, I get a NullReferenceException...in the UIApplication.Main() function that gets called in the iOS project's Main class. There's nothing special in that class at all, though.
It gets better. If I do something else first, like dragging and dropping the items in the SfListView to reorder them and then I scroll it, it doesn't throw the exception.
What on Earth could be causing this?
Here is the XAML for one of the pages that uses the SfListView:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:syncfusion="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms"
mc:Ignorable="d"
x:Class="Partylist.Views.EventsPage"
Title="Events"
BackgroundColor="White">
<ContentPage.ToolbarItems>
<ToolbarItem IconImageSource="settings_gear.png"
Priority="0"/>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<!--Main layout of the page-->
<StackLayout>
<!--ListView of the events-->
<syncfusion:SfListView x:Name="EventsListView"
SelectionMode="Single"
SelectionGesture="Tap"
SelectionChanged="OnItemSelected"
DragStartMode="OnHold">
<syncfusion:SfListView.DragDropController>
<syncfusion:DragDropController UpdateSource="True"/>
</syncfusion:SfListView.DragDropController>
<syncfusion:SfListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<SwipeView>
<!--Swipe from the right to make some options
appear-->
<SwipeView.RightItems>
<SwipeItems>
<SwipeItem Invoked="OnDelete"
CommandParameter="{Binding .}"
Text="Delete"
BackgroundColor="#ff418b"
IsDestructive="true"/>
<SwipeItem Invoked="OnRename"
CommandParameter="{Binding .}"
Text="Rename"
BackgroundColor="#FF7700"/>
</SwipeItems>
</SwipeView.RightItems>
<!--This is the content that actually appears-->
<StackLayout Padding="20,5">
<Label Text="{Binding EventFolder.Name}"
TextColor="#FF7700"
FontSize="Large"/>
</StackLayout>
</SwipeView>
</ViewCell>
</DataTemplate>
</syncfusion:SfListView.ItemTemplate>
</syncfusion:SfListView>
<!--"New Event" button-->
<Button Text="+ Add New Event"
TextColor="#ff418b"
FontSize="Large"
BackgroundColor="#00ffffff"
Clicked="OnNewEventClicked"/>
<!--The banner at the bottom of the screen that gives tips-->
<Frame BorderColor="#ff418b"
Padding="0"
HeightRequest="75">
<FlexLayout Direction="Row"
AlignItems="Stretch"
JustifyContent="SpaceBetween">
<!--The "Tip" icon-->
<Image Source="tip_icon.png"
Margin="10"
FlexLayout.Basis="50"/>
<!--The short version of the tip-->
<Label x:Name="tipLabel"
VerticalTextAlignment="Center"
TextColor="#bb0099"
FontSize="Medium"
FontAttributes="Bold"
FlexLayout.Basis="240"/>
<!--The button that opens up a screen
with the rest of the tip-->
<Button Clicked="OnMoreClicked"
Text="More"
TextColor="White"
FontAttributes="Bold"
FontSize="Medium"
BackgroundColor="#ff418b"
FlexLayout.Basis="100"/>
</FlexLayout>
</Frame>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Here is the iOS project's Main class:
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace Partylist.iOS
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate"); // This is the line that throws the exception.
}
}
}
UPDATE: I just applied the SfListView to a couple more pages in my project and I couldn't type into the entries in the items on those pages' lists or use their SwipeViews (the experimental ones in Xamarin, not the ones from the SfListView) without crashing the app in the same way as above.
I just got rid of the Synfcusion ListView and switched back to the one that Xamarin comes with. #BenReierson said it's a problems with Xamarin, so maybe I'll look into switching back when that bug gets fixed.
Glad to inform that the reported issue “NullReferenceException throws when scrolling the SfListView with DragDropController” has been included in Syncfusion's latest Weekly NuGet release update version 18.2.0.46 which is available for download (https://www.nuget.org/).

x:Bind Design Time issues

I am trying to build my UWP app and currently am stuck with designer exceptions when trying to use DataTemplate with x:Bind in a Resource Dictionary.
I have created a Resource Dictionary "ItemTemplates.xaml" with a respective code-behind (to ensure x:Bind initialization). The file contains just one template:
<DataTemplate x:Key="HomeViewCategoryListItemTemplate" x:DataType="models:Category">
<Button Background="#88333333" Height="110" VerticalContentAlignment="Top" Padding="10" HorizontalAlignment="Stretch">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock FontWeight="Light" HorizontalAlignment="Center" Text="{x:Bind Name}" FontSize="{ThemeResource TextStyleExtraLargeFontSize}" />
<TextBlock Foreground="{ThemeResource ToolTipForegroundThemeBrush}" HorizontalAlignment="Center" Margin="0,10,0,0" Text="{x:Bind Description}" Grid.Row="1" TextAlignment="Center" TextWrapping="Wrap" />
</Grid>
</Button>
</DataTemplate>
Then I added this resource dictionary to App.xaml like this:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Resources/Core.xaml" />
<resources:ItemTemplates />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Now the project is unusable, because designer throws weird exceptions, but when I Clean and Rebuild the project and navigate to the HomeView.xaml page, the designer shows just the default "ToString()" items (basically the list view contains just three times the text "Models.Categories") in the ListView and the ItemTemplate property of my ListView is underlined and shows the following error:
The resource "HomeViewCategoryListItemTemplate" could not be resolved.
When I navigate back to App.xaml, I see yet another underline there (of the <resources:ItemTemplates /> line) which says:
The property 'DataType' was not found in type 'DataTemplate'.
Both errors are non-sensical, because when I actually run the app, there are no issues and everything works perfectly. The only workaround I have found so far is to include the ResourceDictionary two times in both the classic way and the "compiled" way:
<ResourceDictionary Source="ItemTemplates.xaml" />
<resoures:ItemTemplates />
This solution works and then everything works both in design time and in run-time, but I really think it is quite messy and there has to be a better, safer approach or I am missing something trivial.
I am running Visual Studio 2015 Update 1 and have the newest UWP SDK installed. The project targets build 10240.
Edit:
Another exception that the designer very often throws and crashes completely:
Unable to cast object of type 'System.String' to type 'Models.Data.Categories.Category'.
According to the StackTrace output this happens inside the ItemTemplates.xaml.cs code - specifically the generated method ProcessBindings. Again, the project still compiles and runs normally, but the designer does not even bother trying to show the output.
For this current version, prefer Binding over x:Bind
an answer from a Microsoft engineers
I've got the same problems as you did, plus a ton of bugs when using x:Bind in Design time. Quickest way to fix: use Binding as old time. And when you release, if performance is under consideration, change the Binding to x:Bind

Loading Images from URL freezes the UI on Windows phone

I'm trying to load a list of news from a website, so first I make a request to fetch the news (with the thumbnails), and using the Binding feature, I assign the Fetched news to my list box, which contains the image (ImageUrl).
<ListBox Name="lstNews">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,12,12" Width="180" Height="180">
<Grid.Background>
<ImageBrush ImageSource="{Binding ImageUrl}" />
</Grid.Background>
<StackPanel Background="#AA000000" VerticalAlignment="Bottom" Height="60" >
<TextBlock TextWrapping="Wrap" VerticalAlignment="Bottom" TextAlignment="Center" Text="{Binding Title}" />
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
It works fine, but the UI freezes until the images show up. how can I fix that?
Actually, BitmapImages by default do load on the UI thread, which would cause the blockage. In your xaml, you should be able to do something like:
<ImageBrush>
<ImageBrush.ImageSource>
<BitmapImage CreateOptions="BackgroundCreation" UriSource="{Binding ImageUrl}"/>
</ImageBrush.ImageSource>
</ImageBrush>
Making sure to specify BackgroundCreation for the CreateOptions. For more information, I personally found this blog post to be quiet useful.
Have you tested to make sure that your UI does not freeze when you comment out your ImageBrush line? I believe the automatic conversion creates a BitmapImage from your ImageUrl, which normally loads on a background thread, so your UI thread should not block. It is possible that something else altogether is blocking the UI, like excessive amounts of text that needs to be laid out or your data layer code that feeds the list with the data.

WPF Binding Button.Command in ControlTemplate to property of ViewModel

My ViewModel has a property called Commands which is of type IDictionary.
For my data grid I have created a ControlTemplate for one of the fields using a button as follows:
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Button Style="{DynamicResource btnRemove}" Width="14" Height="14"
Content="{TemplateBinding Content} "
CommandParameter="{Binding ViewID}"
Command="{Binding Commands[AcknowledgeErrorCmd]}" />
<ControlTemplate.Triggers>
</ControlTemplate.Triggers>
</ControlTemplate>
Clicking on the button does nothing which tells me the binding did not work. However, an unstyled button added to the toolbar of the same window hosting this grid works, binds properly to this command. I guess my question is:
Hw do I bind the command property of a button used in a ControlTemplate to a ViewModel?
TIA.
I am not sure what the problem is but try to debug your solution and look into the output window with Debug selected in the combobox and you will see the errors that occur during binding. Maybe this will help you to the solution.
Provide me the error as a comment on this post if you don't understand it.
I did this instead:
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Border >
<TextBlock Margin="5">
<Hyperlink
CommandParameter="{Binding ElementName=root, Path=DataContext.ViewID}"
Command="{Binding ElementName=root, Path=DataContext.Commands[AcknowledgeErrorCmd]}">
<TextBlock Text="Acknowledge"/>
</Hyperlink>
</TextBlock>
</Border>
</ControlTemplate>
and that works fine. It may be related to the post Viko provided.

Resources