Equivalent to adControl.HasAd in windows phone 8.0 - c#

In a Windows Phone 8.1 universal app, I could use this Code for a Pub Center ad.
//code behind:
if(adControl.HasAd)
{
}
//xaml:
<UI:AdControl x:Name="adControl" AutoRefreshIntervalInSeconds="60" ApplicationId="" AdUnitId="" HorizontalAlignment="Left" Height="70" IsAutoRefreshEnabled="True" VerticalAlignment="Top" Width="400" Foreground="Black" Background="Black"/>
But this function isn't avaible for a Silverlight App. Does someone know a equivalent to "adControl.HasAd" in a Windows Phone 8.0 App?

I don't think there is an equivalent in WP8.0. What you can do though is have your own bool and set/unset it with the following two events:
adControl.AdRefreshed:
Raised when the AdControl receives a new ad.
and
adControl.ErrorOccured:
Raised when the AdControl receives a new ad.
If you just want to collapse the advert when no ad is shown you can also use:
adControl.IsAutoCollapseEnabled = true;

Related

Open URL in default Web Browser. Windows Phone 8.0 app

I have a hyperlink inside a Text block. I want it to open the link int he web browser, but when I Click it I get a popup saying
"Search an app in the store"
and my app crashes.....
my XAML code is:
<TextBlock HorizontalAlignment="Right" Height="49" Margin="0,0,10,0" TextWrapping="Wrap" Width="326" Foreground="Black" FontSize="16">
<TextBlock.Inlines>
<Hyperlink Click="Hyperlink_Click" NavigateUri="www.bing.com">
<Hyperlink.Foreground>
<ImageBrush Stretch="Fill" ImageSource="Assets/Proceed.png"/>
</Hyperlink.Foreground>Don't have a Selfcare Account ? Register here.</Hyperlink>
</TextBlock.Inlines>
<!--<Hyperlink xml:space="preserve" Foreground="#000" FontSize="16">Don't have a Mobitel Selfacre Account ? Register here. </Hyperlink>-->
</TextBlock>
my CS code is:
private async void Hyperlink_Click(Windows.UI.Xaml.Documents.Hyperlink sender, Windows.UI.Xaml.Documents.HyperlinkClickEventArgs args)
{
await Launcher.LaunchUriAsync(new Uri("www.google.com"));
}
Kindly help me fix it... Any kind of help is appreciated....
Change the uri from www.bing.com to http://www.bing.com. It needs the protocol to determine the application it uses to start the url with.
Check these links for more information:
Auto-launching apps using file and URI associations for Windows Phone 8
URI schemes for launching built-in apps for Windows Phone 8
Reserved file and URI associations for Windows Phone 8

Hub / HubSection in Windows 10 Mobile

I try to migrate my Windows 8.1 application to Windows 10 Mobile (SDK 10240),
But the Hub control doesn't work like in Windows Phone 8.1.
The hub sections are too small or big and don't fit the mobile screen width.
I didn't find any property to solve the problem.
<Hub Background="White" Header="Header">
<HubSection x:Uid="HubSection1" Header="Header1">
<DataTemplate>
<TextBlock Text="Content1" />
</DataTemplate>
</HubSection>
<HubSection x:Uid="HubSection2" Header="Header2" >
<DataTemplate>
<TextBlock Text="Content2" />
</DataTemplate>
</HubSection>
</Hub>
I want it like in Windows Phone 8.1 that the Header1 is in the first page, Header2 in the second, etc...
I created this Behavior to make the Hub control behave like the Windows Phone 8.1 control when running on mobile.
Check it out and tell me if it fixes your problem.

Windows Phone page navigation does not work

I'm new in creating apps for Windows Phone. I've got problem with redirecting to another page. I've created blank page with HyperlinkButtonand in .cs file I wrote this:
private void but_elf_Click(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(Elfy));
}
In xaml:
<HyperlinkButton x:Name="but_elf" Content="Elfy"
HorizontalAlignment="Center" Margin="100,125,100,255" Grid.Row="1"
VerticalAlignment="Center" Width="200" Height="70" />
When I launch app and click on the button - nothing happens. There are no errors, no messages. I've tried to put NavigateUri in button's property but after pressing button (in launched app) the message has shown: "You need to install an app for this task. Would you like to search for one in the Store?" After pressing "Yes" the app says: "Sorry, no apps found".
How to figure out this problem? I'm creating app for Windows Phone 8.1 in .NET Framework 4.5. Thanks for any help.
You are missing a reference for the 'Click'-event handler. Please change your XAML to this:
<HyperlinkButton x:Name="but_elf" Content="Elfy"
HorizontalAlignment="Center" Margin="100,125,100,255" Grid.Row="1"
VerticalAlignment="Center" Width="200" Height="70" Click="but_elf_Click" />
Please see:
C# Documentation for Click on MSDN
C# Documentation for HyperlinkButton on MSDN

How to run video with mediaelement in windows phone 8 app

I am making a windows phone app, I want to run the video whenever the button is pressed. I am using mediaelement to run it, here is the code:
XAML:
<MediaElement x:Name="myMediaElement"
Margin="0,40,0,40"
Height="400"
Width="240" />
<Button x:Name="playVideoButton"
Height="80"
Width="200"
Content="Play Video"
Click="playVideoButton_Click"/>
C#:
private void playVideoButton_Click(object sender, RoutedEventArgs e)
{
myMediaElement.Source = new Uri("ms-appx:///Assets/Video.mp4", UriKind.RelativeOrAbsolute);
myMediaElement.Play();
}
this is the basic code that i am trying to run the video so if this one runs i'll add pause feature as well, but unfortunately its not running.
Please help and thanks in Advance!
Shahrukh
you can refer a Nokia Developer Sample about Video Playback with MediaElement in Windows Phone or you can Use Media Player launcher instead. here is a MSDN Documentation about it. How to use the Media Player launcher for Windows Phone 8

Adcontrol Windows Phone does not show

I have read this (similar) question: Windows phone ads not working
And I have read this blog post. But it still does not work.
I have the feeling that it has something to do with my references. Or is it that it does not show up debugging the app on my phone? (because my cpu is too old to run emulation)
my xaml:
xmlns:ads="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI"
and below:
<ads:AdControl x:Name="showMeTheMoney"
ApplicationId="a pubcenter id"
AdUnitId="a pubcenter ad unit id"
HorizontalAlignment="Left"
Height="80" Margin="0,0,0,0"
Grid.Row="1"
VerticalAlignment="Top"
Width="480"/>
in pubcenter I have registered the app and adunit and also the size (480 x 80)
But it is still a black square on my phone.
Also the manifest has the required rights:
Ads using real ApplicationId and AdUnitId are not working in emulator, for testing you should use test values located here:
Test Values for AdUnitId and ApplicationId

Categories

Resources