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
Related
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.
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
I was trying to implement the sample app of running a wav file as shown in the microsoft virtual academy tutorial for beginners. I tried implement same code and ran app but my app does not play sound of wav file. I am running the app on emulator. and following is the code i implemented in xaml file:
<MediaElement x:Name="Quack" HorizontalAlignment="Left" Height="128" Margin="314,218,0,0" Grid.Row="1" VerticalAlignment="Top" Width="100"
Source="/Assets/quack.wav"
AutoPlay="True" Balance="1" Volume="1"/>
following is code in xaml.cs file
private void buttonQuack_Click(object sender, RoutedEventArgs e)
{
textQuack.Text = "Hear the sound";
QuackMediaElement.Play();
}
I just wondered if is there any setting required in emulator in order to enable volume or something
I have a hyperlink button in a pivot that navigates to a Url contained in an object in the ViewModel. When I press the button, I navigate to the url. But when I press the hardware back button, the phone navigates back to the start page.
<HyperlinkButton Content="Read More"
NavigateUri="{Binding Citation}"
BorderBrush="White"
BorderThickness="4"
Grid.Row="2"
HorizontalAlignment="Stretch"
Margin="10" />
When the debugger is attached, the back button navigates back to the app, which is what I want it to do. When it's not attached, and i've tested this on 5 devices and all the emulators, it goes back to the Start page list, and all the input that was supplied to the app is lost. The app seems to be cleared from memory completely. Help? PS I am working in Windows Phone 8.1 RT, not a shared app.
Well, it seems as if I was approaching this the wrong way. Something new in Windows Phone 8.1 RT is the WebView. So no longer does the OS open an IE instance, you can open a webpage inline a grid. So:
<Button Content="Read More"
BorderBrush="White"
BorderThickness="4"
Grid.Row="2"
HorizontalAlignment="Stretch"
Margin="10"
Click="Citation_Click"/>
and then
private void Citation_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(WebViewPage), this.equation.Citation);
}
And in the WebViewPage.xaml.cs:
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
Uri nav = new Uri(e.NavigationParameter as string);
_webView.Navigate(nav);
}
where _webView is defined as:
<Grid>
<WebView x:Name="_webView"/>
</Grid>
in WebPageView.xaml
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;