Last active
August 29, 2015 14:00
-
-
Save igorkulman/11111043 to your computer and use it in GitHub Desktop.
AssociationUriMapper settings for being a share contract target in Windows Phone 8.1 Silverlight app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AssociationUriMapper : UriMapperBase | |
{ | |
public override Uri MapUri([NotNull] Uri uri) | |
{ | |
var op = (Application.Current as App).ShareOperation; | |
if (op != null) | |
{ | |
var link = op.Data.GetWebLinkAsync().GetResults(); | |
return new Uri("/Views/AddedView.xaml?Uri=" + HttpUtility.UrlEncode(link.ToString()), UriKind.Relative); | |
// Otherwise perform normal launch. | |
return uri; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnLaunch(object sender, Microsoft.Phone.Shell.LaunchingEventArgs e) | |
{ | |
base.OnLaunch(sender, e); | |
var shareTargetLaunch = e as ShareLaunchingEventArgs; | |
if (shareTargetLaunch != null) | |
{ | |
(App.Current as App).ShareOperation = shareTargetLaunch.ShareTargetActivatedEventArgs.ShareOperation; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override PhoneApplicationFrame CreatePhoneApplicationFrame() | |
{ | |
var frame = new PhoneApplicationFrame(); | |
frame.UriMapper = new AssociationUriMapper(); | |
return frame; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment