Xamarin: Problem with call on WebView <tel:...link - xamarin

Good evening,
I've been trying to solve the problem with clicking on <tel:....link in webview for a few days now.
I have tried several manuals but none of them work.
Can you please advise me?
Thank you

Use the Webview.OnNavigating event. Something like this should work:
Page.xaml.cs
private void WebView_OnNavigating(object sender, WebNavigatingEventArgs navigationEvent) {
if (navigationEvent.Url.StartsWith("tel:")) {
navigationEvent.Cancel = true;
Xamarin.Essentials.Launcher.OpenAsync(navigationEvent.Url);
}
}
Page.xaml
<WebView Navigating="WebView_OnNavigating" />

Related

developing a picker that pops out from the selected frame downward in xamarin forms

I have a design i'm trying to implement. Although I've ben working with Rg.plugin for a while trying out different animations and entry behaviour but it's always covering the whole screen.
However, the current design I'm working with is different.
here is the image
Please does anyone have an idea how I can achieve this using xamarin forms please.
Any help will be appreciated.
Note, I already have the design in place using pancakeView and Rg.plugin to pop it out on click. However, the positioning is what I haven't been able to achieve. though I've not written any code for it yet cos I prefer to do my research right.
Please I need anyone to point me to the right path or how to achieve this.
thanks in advance
According to your screenshot, you can do custom control using entry and ListView to get it, there is also one custom control that you can take a look:
Installing Xamarin.Forms.EntryAutoComplete
Uisng this custom control like:
<ContentPage
x:Class="demo3.listviewsample.Page36"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:customControl="clr-namespace:EntryAutoComplete;assembly=EntryAutoComplete">
<ContentPage.Content>
<StackLayout>
<customControl:EntryAutoComplete
ItemsSource="{Binding Countries}"
MaximumVisibleElements="5"
Placeholder="Enter country..."
SearchMode="{Binding SearchMode}"
SearchText="{Binding SearchCountry}"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
public class dialogvidemodel:ViewModelBase
{
private string _searchCountry = string.Empty;
private SearchMode _searchMode = SearchMode.Contains;
public string SearchCountry
{
get => _searchCountry;
set
{
_searchCountry = value;
RaisePropertyChanged("SearchCountry");
}
}
public List<string> Countries { get; } = new List<string>
{
"African Union",
"Andorra",
"Armenia",
"Austria",
"Togo",
"Turkey",
"Ukraine",
"USA",
"Wales"
};
public SearchMode SearchMode
{
get => _searchMode;
set
{
_searchMode = value;
RaisePropertyChanged("SearchMode");
}
}
}
More detailed info, please take a look:
https://github.com/krzysztofstepnikowski/Xamarin.Forms.EntryAutoComplete

using TabControl in windows phone

I read the article about using a TabControl on Windows Phone application. I can avoid it to fire when it is first load. However, the selectionChanged fired twice when user click the tab. Would someone can help me how to fix it. Thanks in advance.
There is my TabControl:
<cc:TabControl Grid.Row="1" SelectionChanged="tabList_SelectionChanged" x:Name="tabList">
<cc:TabItem Height="80" Header="Events" Foreground="Black"/>
<cc:TabItem Height="80" Header="Details" Foreground="Black"/>
<cc:TabItem Height="80" Header="Notes" Foreground="Black" />
</cc:TabControl>
There is cobe behind:
public partial class Tab : PhoneApplicationPage
{
private bool blnFristLoad=true;
public Tab()
{
InitializeComponent();
tabList.SelectionChanged += new SelectionChangedEventHandler(tabList_SelectionChanged);
}
private void tabList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (blnFristLoad == false)
{
TabItem t = (sender as TabControl).SelectedItem as TabItem;
t.Content = "202020";
}
else blnFristLoad = false;
}
It's very obvious in your code. You are adding SelectionChanged event handler twice. One from your XAML code and the other from the code behind. As you are using += symbol, the eventhandler is added as a seperate instance.
Remove one of those statements.
Please use the Pivot control instead of a TabControl for the WindowsPhone. the Pivot control follows the design guidelines for the phone and looks and feels much better.

Hyperlink button website

I need to put button that after click moves user to website. Can someone tell me what should I put into vb and in xaml?
<HyperlinkButton Content="Click here to learn about Silverlight" NavigateUri="http://www.silverlight.net" TargetName="_blank" />
You can do it also in C#
private void HyperlinkButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
var task = new Microsoft.Phone.Tasks.WebBrowserTask
{
URL = "http://siteaddress.com",
};
task.Show();
}

How to pass a parameter in a button and get value in the code behind to redirect to another page based on the value of parameter in windows phone 7?

I am thinking if the windows phone 7 button event is similar to ASP.NET development with C#, something like in the button, I set value to commandparameter in the XAML, and in the code behind, I get the commandparameter and redirect the page.
I haven't found any good examples for button event handling, any suggestions?
Thank you.
For the xaml:
<Button Tag="pageAddress" Click="Button_Click" />
And then on the code-behind:
private void Button_Click(object sender, RoutedEventArgs e)
{
Button _button = (Button)sender;
NavigationService.Navigate(new System.Uri(_button.Tag.ToString()));
}
I would recommend you use a command parameter as you mentioned. So in your xaml do something like this:
<Button x:name="myButton" CommandParameter="{Binding Title}" Click="myButton_Click"/>
And in your C# code something like this:
private void myButton_Click(object sender, RoutedEventArgs e)
{
Button _myButton = (Button)sender;
string value = _myButton.CommandParameter.ToString();
}
Really it's pretty similar to Teemu's answer although I must admit I haven't used the Tag
element before. According to the documentation on MSDN, the Tag element should work pretty nicely as it can store custom information that you can access in your code behind (or viewmodel).

how to localize a application bar in wp7?

is it possible to localize the application bar?
i made the tutorial on msdn how to localize a application and everything was find. but the method with:
{Binding Localizedresources.Today, Mode=OneWay}
dont work on the app. bar
what can i do?
If you don't want to use a 3rd party solution like James Cadd suggested, you may create the application bar from your code-behind and using your resources to fill-in the Text-property:
public MainPage() {
InitializeComponent();
Loaded += MainPage_Loaded;
}
void MainPage_Loaded(object sender, RoutedEventArgs e) {
BuildApplicationBar();
}
private void BuildApplicationBar() {
ApplicationBar = new ApplicationBar();
var appBarButtonAdd = new ApplicationBarIconButton(new Uri("/img/add.png", UriKind.Relative)) { Text = AppResources.ABAdd };
appBarButtonAdd.Click += newEntry_Click;
ApplicationBar.Buttons.Add(appBarButtonAdd);
var appBarMenuReview = new ApplicationBarMenuItem(AppResources.ABMarketplace);
appBarMenuReview.Click += review_Click;
ApplicationBar.MenuItems.Add(appBarMenuReview);
}
There are a few implementations of a bindable ApplicationBar for WP7, you might try one of these:
http://www.maxpaulousky.com/blog/archive/2011/01/10/bindable-application-bar-extensions-for-windows-phone-7.aspx
http://dotnetbyexample.blogspot.com/2011/02/case-for-bindable-application-bar-for.html
You haven't included much to work with, but I wrote a pretty good (I think) blog on the subject, including code from start to finish on localizing an app. It covers localization from start to finish, with screenshots and downloadable code, including the application bar.

Resources