setting state of windows phone toolkit toggle switch - windows-phone-8

I'm working on a windows phone 8 application. I want to use toggle switch for some purposes. Sadly windows phone 8 does not have that controller. So i had to install windows phone toolkit nuget package.
Now I want to set the state(some thing like isChecked=true). but I couldn't find any method to use.
can someone please help me.

Try this on Button Click
private void Button_Click(object sender, RoutedEventArgs e)
{
if (toggleSwitch.IsChecked == true)
toggleSwitch.IsChecked = false;
else
toggleSwitch.IsChecked = true;
}
It is Working....

Related

share option in windows phone app

i wanna provide share option from my windows app to another apps in my windows phone, like android develpement. please any one tell, is it possible in windows phone. (using RT, not in silver Light) Thank You in advance.
For example: like the below image
I am using below code using "How to use ShareLinkTask namespace in Windows Phone 8.1?" link.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
DataTransferManager dtManager = DataTransferManager.GetForCurrentView();
dtManager.DataRequested += dtManager_DataRequested;
}
private async void dtManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
e.Request.Data.Properties.Title = "Code Samples";
e.Request.Data.Properties.Description = "Here are some great code samples for Windows Phone.";
e.Request.Data.SetWebLink(new Uri("http://code.msdn.com/wpapps"));
}
// Click Button to share Web Link
private void btnShareLink_Click(object sender, RoutedEventArgs e)
{
Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI();
}
but it displays a progress bar with a message Preparing content to share and then it disappears, with no UI for sharing.
what should I do.please help me.

Windows phone 8.1 ink manager alternative

I have an universal app and the windows version use ink manager to capture a signature. I want to do the same with the phone but the ink manager dont exist. Does anyone have or know an alternative.
I added a canvas named Display and add this code using two events.
private Point _currentPoint;
private Point _oldPoint;
private async void Display_PointerMoved(object sender, PointerRoutedEventArgs e)
{
DrawPoint(e);
}
private void DrawPoint(PointerRoutedEventArgs e)
{
_currentPoint = e.GetCurrentPoint(this).Position;
Line linea = new Line
{
Stroke = new SolidColorBrush(Colors.Black),
StrokeThickness=1,
X1 = _currentPoint.X,
Y1 = _currentPoint.Y,
X2 = _oldPoint.X,
Y2 = _oldPoint.Y
};
Display.Children.Add(linea);
_oldPoint = _currentPoint;
}
private void Display_PointerPressed(object sender, PointerRoutedEventArgs e)
{
_currentPoint = e.GetCurrentPoint(this).Position;
_oldPoint = _currentPoint;
}
Input: XAML user input events sample in Microsoft MSDN code has a sample using pointer events with both C# and Visual Basic. Specifies Visual Studio 2013 but will probably upgrade with a later version of Visual Studio. And this example looks to be for Windows 8.1 however you might be able to use that as a starting place.

Windows Phone 8 - Message Box alternative

I have to develop an app for Windows Phone 8. I want the user to be briefly notified without force him to face a Message Box (and consequently having to press a button to dismiss it). Are there any alternatives? I'm from Android and something similar to a Toast would be perfect. Also having the opportunity to change the text color would be nice.
Thank you in advance.
There are toasts in Windows Phone as well but AFAIR they can be used only when your app is in the background. But there is a solution: ToastPrompt class from Coding4Fun toolkit which is visually equal to toast notification.
See details:
https://stackoverflow.com/a/13981508/1985167
You can use ToastPrompt from Coding4Fun toolkit,
like this,
private void ToastWrapWithImgAndTitleClick(object sender, RoutedEventArgs e)
{
var toast = GetToastWithImgAndTitle();
toast.TextWrapping = TextWrapping.Wrap;
toast.Show();
}
private static ToastPrompt GetToastWithImgAndTitle()
{
return new ToastPrompt
{
Title = "With Image",
TextOrientation = System.Windows.Controls.Orientation.Vertical,
Message = LongText,
ImageSource = new BitmapImage(new Uri("../../ApplicationIcon.png", UriKind.RelativeOrAbsolute))
};
}

Trigger a phone call in Windows Phone 8 application

I need to develop an app to make a call from the Windows Phone 8 app using Visual Studio.
But I couldn't find any resources to do it.
When a button is clicked I need to call to a mobile number which is already given.
By clicking that button I must call only to that mobile number.
This is what I coded. When a given button is clicked, I this method is calling...
private void HyperlinkButton_Click_1(object sender, RoutedEventArgs e)
{
PhoneCallTask phoneCallTask = new PhoneCallTask();
phoneCallTask.PhoneNumber = "0719957868";
phoneCallTask.DisplayName = "Gage";
phoneCallTask.Show();
}
But I get an unhandled exception.
Unhandled exception.
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
Debugger.Break();
}
}
When you use PhoneCallTask, you have to specify a new Capability of your app in WMAppManifest.xaml: ID_CAP_PHONEDIALER
source
This is how you should do it:
PhoneCallTask phoneCallTask = new PhoneCallTask();
phoneCallTask.PhoneNumber = "2065550123";
phoneCallTask.DisplayName = "Gage";
phoneCallTask.Show();
Remember that the call is not automatically started but it prompts the user to confirm that action.
Here is how to initiate a call on windows phone
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394025(v=vs.105).aspx
Ok for future reference i must add this.
If you get an Unauthorized Access Exception then you need to enable ID_CAP_PHONEDAILER from the Capabilities section in the WMAppManifest.xml file.
See here

Using a ToggleSwitch in App Settings

I want to use ToggleSwitch in the app settings. I am not able to save its state on IsolatedStorage so that it can be reflected on the MainPage. I have tried using the available Key/Value pair storage examples on msdn to perform this but have not been able to. Please write a precise solution if anyone knows.
Here you go:
in your settings page XAML
<toolkit:ToggleSwitch Header="Push Notifications"
Checked="PushNotificationsToggle_Checked" Unchecked="PushNotificationsToggle_Unchecked">
</toolkit:ToggleSwitch>
in your settings page code behind
private void PushNotificationsToggle_Unchecked(object sender, RoutedEventArgs e)
{
var settings = IsolatedStorageSettings.ApplicationSettings;
settings["PushNotifications"] = false;
settings.Save();
}
in your main page you can use this setting like this
var settings = IsolatedStorageSettings.ApplicationSettings;
Boolean usePushNotifications = (Boolean)settings["PushNotifications"]