I'm trying to work something out and can't seem to get the final piece together. I have a Windows Phone app that displays images from Flickr and what I want to do is allow the user to save the image that is on the phone screen to their Media Library. I've employed the Hold Gesture to do this and I need some help getting the context menu to pop-up after the user holds down on the image. I'm not sure how to get the menu to pop up. Here is the Hold-Code I'm trying to use. There is something I'm missing here.
private void Image_Hold(object sender, System.Windows.Input.GestureEventArgs e)
{
var img = sender as System.Windows.Controls.Image;
var url = (string)img.Tag;
}
Thanks for any help.
It is possible to save an Image to the MediaLibrary on Windows Phone 7 and 8.
There are...
Blogs with code snippets
MSDN documentation
Lots of previous answers on Stackoverflow.
Related
I'm using mediaelement in my windows phone 8.1 app. I have some others button too. When I use buttons it's a link to a website. When I use back button to back to my mainpage the mediaelement stop working. What can I do?
//this is my media element in xaml
<MediaElement x:Name="nima" Source="assets/jadid.mp3" AutoPlay="True"/>
I even use:
private void Application_Activated(object sender, ActivatedEventArgs e)
{
nima.Play();
}
But it's not working. Please help me.
If you want to play audio when your application is not in the foreground then you need to create a Background Audio Task and include that inside your solution.
See MSDN: Background Audio for Windows Phone 8.1 Sample for complete tutorial and project files.
I would like to zoomout the image from the flipView available in the GridProject of Win8 Metro App in C# XAML. I already have a scrollviewer but I would like to know if the user can simply double the image with mouse, so that only the image gets opened in a new page.
If so, it would be really great if you could suggest me how to proceed with it.
I followed this article Zooming into image in Windows Store appsSemanticZoom but it doesn't help.
Thanks in Advance!
While certifiying my Phonegap App for Windows Phone 7 I was told that the back-button doesn't work the way it should. My application only has one page, so here it's not a problem but it is possible to display a menu using javascript.
When this menu is open, the back-button is supposed to close the menu instead of exiting the application. Does anyone have an idea on how I could easily catch the event of a click on the back-button in order to check if the menu is open and then close it or completely exit the application if it isn't?
I tried document.addEventListener("backbutton", onBackKeyDown, false); but apparently this does not work for Windows Phone 7!
Thanks a lot
WP7 PhoneGap definitely supports the back button. You can download a working example from my blog here:
http://www.scottlogic.co.uk/blog/colin/2011/11/handling-the-back-stack-in-windows-phone-7-phonegap-applications/
Make sure you handle the deviceready event first.
Why don't you use the native Silverlight.
XMAL
BackKeyPress="PageBackKeyPress"
Code-Behind
private void PageBackKeyPress(object sender, CancelEventArgs e)
{
// DO NOT CLOSE
if (Something)
e.Cancel = true;
}
I have the same problem. When you write
document.addEventListener("backbutton", onBackKeyDown, false);
That will block the the default backbutton handler. So you may need to do so tricks in the phonegap code. It's not the best way, but it's quite easy though. Check out this one:
http://blog.projectdebug.com/?p=6
I need to create a MediaElement that will keep playing when I navigate to different pages within my app. Any ideas on how to do this?
I actually just found a solution. As so often before once you write down a question you get an idea that works yourself :)
private MediaElement _mediaElement;
...
_mediaElement = new MediaElement {Volume = 1, AutoPlay = false};
var _pop = new Popup {Child = _mediaElement, IsOpen = true};
This works - in case anybody else runs into the same problem...
I don't think that is possible.
MediaElement is a UIElement which must be hosted inside a page to work.
Each time you navigate, a new page instance is loaded in WP7. A really ugly hack might work, but I don't recommend it.
What are you trying to do?
You could remember the position it was at and restart it when back on page.
If you want to have music that will play throughout an application, consider using the MediaPlayer class.
Alternatively you re-template the PhoneApplicationFrame and put it there. I'm using this solution in my app and I like it better than the popup solution because you can layout the mediaelement along with everything else (like the appbar) if you want controls and stuff.
I had a similar problem and I post on my blog a soltuion.
Silverlight for Windows Phone 7 is based on the page navigation system. Key point is the lifetime of pages – each page is deleted while you navigate to another. To have an object - a singleton for example - during the whole application life it could be placed in App class (App.xaml.cs file). MediaElement is definitely an object that should be one (there must be only one music player). The best and simple solution is place the MediaElement in XAML(it needs to be a part of visual tree), I have used application resources:
<!--Application Resources-->
<Application.Resources>
<MediaElement x:Name="mediaPlayer" Source="/Sound/horrorSong.mp3" AutoPlay="False" />
</Application.Resources>
Then to get it from any page use resources as a dictionary:
MediaElement player = null; // get the media element from App resources
if (App.Current.Resources.Contains("mediaPlayer"))
{
player = App.Current.Resources["mediaPlayer"] as MediaElement;
}
if (player != null)
{
player.Play();
}
It is worth notice that MediaElement can’t play the music while Zune is connect. It is a good idea to prompt the user about it. In a method
if (NetworkInterface.GetIsNetworkAvailable())
{
if (NetworkInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
{
zuneTextBlock.Visibility = System.Windows.Visibility.Visible;
return;
}
}
zuneTextBlock.Visibility = System.Windows.Visibility.Collapsed;
This code does not guarantee if Zune is on (User still could have the phone plugged) but is very likely that Zune is running(Zune starts while phone is connecting).
I found this solution: http://www.jayway.com/2010/10/04/enable-background-audio-for-multiple-pages-in-windows-phone-7/
Works on WP8.
I want to offer a Pin to Start menu command when the user presses and holds on certain sections within my Windows Phone 7 app, as utilized within many other apps. How can this be done?
Unfortunately, this is not available in the current version of the operating system, and framework for third party application developers. Clearly the capability is there because various pre-installed applications (Office, Maps, etc) do this, but it's not available to developers like you and me.
now be done from the upgrade to handle with silverlight toolkit, this is the code you need to use for the button and assign it only created the animated tile, you can add more properties these are the ones I use.
private void CreateLiveTile(object sender, EventArgs e)
{
var newTile = new StandardTileData()
{
Title = "Draw Anime",
BackgroundImage = new Uri("icon2.png", UriKind.Relative),
BackBackgroundImage = new Uri("icon1.png", UriKind.Relative),
Count = 42,
};
ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), newTile);
}
You could think about a workaround in your app, let user to decide which page will be his start page, pin app from menu, and on app start navigate to page user decided to become his start page.
It's really sad that we can't pin any page to Start Screen directly...