How to make phone numbers into clickable links in Windows Phone? - windows-phone-8

In Android development, I'm able to use the Linkify object to transform a phone number into a clickable link that will present the phone's dialler to the user.
Is this possible with Windows Phone? If so, how can I make a phone number into a clickable link?

PhoneCallTask MSDN
What you could do is make a textblock that looks clickable. Then on its click event launch the PhoneCallTask
PhoneCallTask pct = new PhoneCallTask();
pct.PhoneNumber = "1112223333";
pct.Show();

I think you are trying to apply a style to a text which is detected to be a number?
If i guest what are you trying to do, then create a style for your text and do this:
if (var something == phonenumber) //think of a logic to detect that
{
something.Style = (Style)this.Resources["YourStyleKey"];
}

Related

Can Sikuli be used for web testing?

I was working with Sikuli for desktop application like notepad,
but want to know like can I open new tab in browser using Sikuli?
Yes, using Sikuli you can also automate browser. Take images of required web elements (Open new tab button in your case) and stimulate click action using Sikuli APIs.
Yes, you can use Sikuli for web testing.
In this code example, you can use sikuli app to: open browser --> New tab --> Give a like on a webpage (UTAD in this case):
click("mozilla_icon.png")
click("nova_aba.png")
click("endereco.png")
paste("www.utad.pt")
type(Key.ENTER)
wait(8)
click("like_btt.png")
wait(5)
Images of sikuli code:
yes you can use sikuli for performing open tab first take the image of new tab control like in case of FF https://drive.google.com/file/d/0B09BIsDTY_AuZFpMWko1U3BFc0E/view?usp=sharing .Save this image on you local machine. But make sure that image which is used for reference is visible on screen.Call the function mentioned below by and give it Absolute path to above mentioned image.
//provide absolute path in img
public void click_Image(String img)
{
s = new DesktopScreenRegion();
target = new ImageTarget(new File(img));
r = s.find(target);
// Create a mouse object
mouse = new DesktopMouse();
// Use the mouse object to click on the center of the target region
mouse.click(r.getCenter());
}

Windows Phone 8.1 (runtime) additional data in OnMapTapped event

I am trying to create a Windows Phone 8.1 (Runtime) app that has a Map Control on it. I would like to attach additional data to the OnMappedTapped event or a way to grab an assigned Location ID when someone clicks on the MapIcon. Is this possible?
Yes. If you want to do something when someone clicks on a MapIcon (pushpin), then add a tap to the map and then do a search for elements that intersect the touch point using the Map.FindMapElementsAtOffset method: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.maps.mapcontrol.findmapelementsatoffset.aspx
or the Map.FindSubElementsForTouchTargeting method: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.uielement.findsubelementsfortouchtargeting.aspx
When it comes to storing or associating data to a pushpin, I like to store my data in the standard Tag property as that's something I've been doing for a while with WPF and Silverlight. You will notice that the MapIcon/MapElement classes do not have a Tag property, however they are DependancyObjects which meanswe can easily add custom properties to these classes. Here is a simple extension I often use in my WP apps to add a Tag property to these classes.
public static class MapElementExt
{
public static readonly DependencyProperty TagProperty = DependencyProperty.Register("Tag", typeof(object), typeof(MapElement), new PropertyMetadata(null));
}
You can then set this value like this:
pushpin.SetValue(MapElementExt.TagProperty, MyPinData);
Personally, when it comes to pushpins I normally don't mess with the MapIcon/MapElement classes and just create a UIElement for my pushpin. By doing this I can easily have a lot more control over creating my pushpin and can also easily add Tap events. You can specify the location for a UIElement like this:
MapControl.SetLocation(pushpin, MyGeopoint);
And then add the pushpin to the Map.Children property.
If you want to get the coordinates for a randomly selected point on a map through a touch event you can take the pixel coordinates from the tap event and pass them through the Map.GetLocationFromOffset method. For example:
MyMap.Tapped += (s, e) =>
{
Geopoint loc;
MyMap.GetLocationFromOffset(e.GetPosition(MyMap), out loc);
};

Windows Phone 8.1 Has No Sample Images?

I am testing PhotoChooserTask in my 8.1 app and I do not see any available sample images that come with the emulator? Is there a way to get sample images?
void photoChooserTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
//MessageBox.Show(e.ChosenPhoto.Length.ToString());
//Code to display the photo on the page in an image control named myImage.
System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
bmp.SetSource(e.ChosenPhoto);
myImage.Source = bmp;
}
}
You don't need to download from the Internet. I found a great workaround for this.. In the new WP8.1 emulator you have the option to emulate a SD card. Its great. I have created a blog post and a YouTube video. Have a look. Hope it helps.
http://wpdevkvk.wordpress.com/2014/07/19/adding-your-own-photos-to-windows-phone-8-1-emulator/
In the Windows Phone 8.1 emulator there aren't any images available. Actually there are some images for selecting as the background for the start screen, but it is only available for start+theme app in settings page. You can't access them. But you have a workaround for that. Before you test your app you can open the camera app and take some photos. (Obviously it will take save some images of random squares but it will have to do) Then next time you run the app your PhotoChooserTask has some photos to select from.

Animation of Images in Windows phone 8

I am new in Windows Phone, and I've used AnimationArray in iOS to achieve the animation property of multiple images but I'm not sure how to accomplish the same in Windows Phone 8. Has anyone done this before?
You can create an array of images - use BitmapImage[] for that. Then, using a Timer with specified interval, change the Source property for a Image XAML element.

How does one implement pull-to-refresh with a LongListSelector in Windows Phone 8?

I am writing a new WP8 app using the off-the-shelf LongListSelector that is shipped in the Microsoft.Phone.Controls assembly. Can anyone provide a code example that implements pull-to-refresh, originally made popular by Tweetie for iPhone and now common on iOS and Android? The existing examples use non-standard controls and I'd like to maintain my use of LongListSelector in WP8.
EDIT
I have found a good answer on StackOverflow describing the Twitter sample and how to do this in more detail:
Continuous Pagination with LongListSelector
You do not.
Pull-to-refresh is not a standard Windows Phone interaction, and you therefore should not implement it.
No native/first-party Windows Phone application use this functionality, and almost no third-party application does either. There is a reason for that.
To refresh the content of a page (or in your case, a LongListSelector), you should use a refresh ApplicationBacIconButton, just like in the Mail app. That's the standard and preferred way to manage refreshes.
Windows Phone is not Android, nor is it iOS. Keep that in mind when designing an application for it.
It is not a zoo, there are rules.
Actually, I just discovered a project uploaded to the Windows Phone Dev Center on November 30, 2012 that implements "infinite scrolling" using Twitter Search and Windows Phone 8 LongListSelector.
Download this project at: http://code.msdn.microsoft.com/wpapps/TwitterSearch-Windows-b7fc4e5e
If you really must do this (see answer by Miguel Rochefort) then details can be found at http://blogs.msdn.com/b/jasongin/archive/2011/04/13/pull-down-to-refresh-a-wp7-listbox-or-scrollviewer.aspx
Basically, the ScrollViewer has hidden/undocumented states that allow for detecting "compression" at the top or bottom of the list and you can use this to trigger the loading.
This is not completely trivial, but one way of doing it is to use GestureService
this.gestureListener = GestureService.GetGestureListener(containerPage);
this.gestureListener.DragStarted += gestureListener_DragStarted;
this.gestureListener.DragCompleted += gestureListener_DragCompleted;
this.gestureListener.DragDelta += gestureListener_DragDelta;
However, it has some bugs. For example, DragCompleted is not always raised, so you need to double-check for that using ManipulationCompleted event, which seems to be more reliable.
containerPage.ManipulationStarted += delegate { this.manipulationInProgress = true; };
containerPage.ManipulationCompleted += delegate
{
this.manipulationInProgress = false;
PerformDragComplete();
};
Another issue is that DragDelta occasionally reports bad coordinates. So you would need a fix like this:
Point refPosition = e.GetPosition(null);
if (refPosition.X == 0 && refPosition.Y == 0)
{
Tracer.WriteLine("Skipping buggy event");
return;
}
Finally, you can find if list is all the way at the top:
public double VerticalOffset
{
get
{
ViewportControl viewportControl = this.FindChildByName("ViewportControl") as ViewportControl;
if (viewportControl != null)
{
Tracer.WriteLine("ViewPort.Bounds.Top=" + viewportControl.Bounds.Top + " ViewPort.Top=" + viewportControl.Viewport.Top.ToString() + " State=" + this.ManipulationState);
return viewportControl.Bounds.Top - viewportControl.Viewport.Top;
}
return double.NaN;
}
}
You can check out the samples in
https://github.com/Kinnara/WPToolkit
it has an excellent implementation something called a ListView extension of the longllistselector control, that will really help you out.
and remember with longlistselector always try to load 20 items atleast. =)
As the WP8 LLS doesn't use a scrollviewer, I guess you will have to inspect the UI tree to get a hold on the viewport control and see what you can do with ViewportControl.Viewport property ...
Oh ... the twitter application is now using the pull to refresh interaction. I like the UI guidelines of the WP platform but rules, once mastered, are made to be broken ;)
This post here can give you hints on how to get the viewport control and retreive the scrolling offset. this scrolling offset must be of a particular value when the list is bouncing