This question is locked. New answers and comments are not allowed.
How do I actually get this to work in a page? I've tried to insert it as I would a normal control from the toolbox menu but cannot find it and when I try to add it to the menu I still cannot find it?
Edit: Now on page in xaml but causes an exception when I try to set the isrunning to true:
When I check, busyidicator is returning a null reference?
Edit: Now on page in xaml but causes an exception when I try to set the isrunning to true:
<
phone:PhoneApplicationPage
x:Class
=
"Cloud_Connect_for_Rackspace.MainPage"
xmlns:phone
=
"clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell
=
"clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:telerikPrimitives
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Primitives"
xmlns:telerikCore
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Core"
mc:Ignorable
=
"d"
FontFamily
=
"{StaticResource PhoneFontFamilyNormal}"
FontSize
=
"{StaticResource PhoneFontSizeNormal}"
Foreground
=
"{StaticResource PhoneForegroundBrush}"
SupportedOrientations
=
"Portrait"
Orientation
=
"Portrait"
shell:SystemTray.IsVisible
=
"True"
>
<
phone:PhoneApplicationPage.ApplicationBar
>
<
shell:ApplicationBar
>
<
shell:ApplicationBarIconButton
x:Name
=
"btnLogin"
IconUri
=
"/Icons/check.png"
IsEnabled
=
"True"
Text
=
"login"
Click
=
"btnLogin_Click"
/>
</
shell:ApplicationBar
>
</
phone:PhoneApplicationPage.ApplicationBar
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"Transparent"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
telerikPrimitives:RadBusyIndicator
x:Name
=
"busybar"
Grid.RowSpan
=
"2"
AnimationStyle
=
"AnimationStyle9"
Foreground
=
"{StaticResource PhoneAccentBrush}"
Background
=
"{StaticResource PhoneBackgroundBrush}"
Canvas.ZIndex
=
"1"
/>
<
StackPanel
x:Name
=
"TitlePanel"
Grid.Row
=
"0"
Margin
=
"12,17,0,28"
>
<
TextBlock
Text
=
"Cloud Connect - Rackspace Edition"
Style
=
"{StaticResource PhoneTextNormalStyle}"
Margin
=
"12,0"
/>
<
TextBlock
Text
=
"Login"
Margin
=
"9,-7,0,0"
Style
=
"{StaticResource PhoneTextTitle1Style}"
/>
</
StackPanel
>
<
Grid
x:Name
=
"ContentPanel"
Grid.Row
=
"1"
Margin
=
"12,0,12,0"
>
<
TextBox
x:Name
=
"txtUsername"
HorizontalAlignment
=
"Left"
Height
=
"72"
Margin
=
"0,214,0,0"
TextWrapping
=
"Wrap"
VerticalAlignment
=
"Top"
Width
=
"456"
/>
<
PasswordBox
x:Name
=
"txtPassword"
HorizontalAlignment
=
"Left"
Margin
=
"0,317,0,0"
VerticalAlignment
=
"Top"
Width
=
"456"
/>
<
RadioButton
x:Name
=
"radioUK"
Content
=
"UK Account"
HorizontalAlignment
=
"Left"
Margin
=
"10,389,0,0"
VerticalAlignment
=
"Top"
Width
=
"216"
/>
<
TextBlock
HorizontalAlignment
=
"Left"
Margin
=
"10,10,0,0"
TextWrapping
=
"Wrap"
VerticalAlignment
=
"Top"
Height
=
"142"
Width
=
"436"
>
<
Run
Text
=
"Welcome to Cloud Connect for the Rackspace Cloud. To begin, please enter your Rackspace login information to continue. We never share or read your login information and your login details are stored securely "
/>
<
Run
Text
=
"on your phone."
/>
</
TextBlock
>
<
TextBlock
HorizontalAlignment
=
"Left"
Margin
=
"10,187,0,0"
TextWrapping
=
"Wrap"
Text
=
"Rackspace Cloud Username:"
VerticalAlignment
=
"Top"
Height
=
"27"
Width
=
"436"
/>
<
TextBlock
HorizontalAlignment
=
"Left"
Margin
=
"10,290,0,0"
TextWrapping
=
"Wrap"
VerticalAlignment
=
"Top"
Height
=
"27"
Width
=
"436"
>
<
Run
Text
=
"Rackspace Cloud "
/>
<
Run
Text
=
"Password"
/>
<
Run
Text
=
":"
/>
</
TextBlock
>
<
RadioButton
x:Name
=
"radioUS"
Content
=
"US Account"
HorizontalAlignment
=
"Left"
Margin
=
"231,389,0,0"
VerticalAlignment
=
"Top"
Width
=
"215"
IsChecked
=
"True"
/>
</
Grid
>
</
Grid
>
</
phone:PhoneApplicationPage
>
using
System;
using
System.Collections.Generic;
using
System.IO;
using
System.Linq;
using
System.Net;
using
System.Xml;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Navigation;
using
Microsoft.Phone.Controls;
using
Microsoft.Phone.Shell;
using
Telerik;
using
Cloud_Connect_for_Rackspace.Resources;
namespace
Cloud_Connect_for_Rackspace
{
public
partial
class
MainPage : PhoneApplicationPage
{
WebClient wc;
public
Rackspace api = App.api;
public
MainPage()
{
InitializeComponent();
}
private
void
btnLogin_Click(
object
sender, EventArgs e)
{
busybar.IsRunning =
false
;
busybar.IsRunning =
true
;
wc =
new
WebClient();
wc.Headers[
"Accept"
] =
"application/xml"
;
wc.Headers[
"Content-Type"
] =
"application/json"
;
wc.UploadStringCompleted +=
new
UploadStringCompletedEventHandler(parseAuthResponse);
try
{
string
json =
"{\"auth\":{\"passwordCredentials\":{\"username\":\""
+ txtUsername.Text +
"\", \"password\":\""
+ txtPassword.Password +
"\"}}}"
;
if
(radioUK.IsChecked ==
true
) wc.UploadStringAsync(api.auth.uk, HttpMethod.Post, json);
else
wc.UploadStringAsync(api.auth.us, HttpMethod.Post, json);
}
catch
(NullReferenceException)
{
MessageBox.Show(
"Please enter your username and password to continue. These are the ones you use to login to the Rackspace Cloud online control panel"
,
"Login Details Missing"
, MessageBoxButton.OK);
}
}
void
parseAuthResponse(
object
sender, UploadStringCompletedEventArgs e)
{
try
{
StringReader stream =
new
StringReader(e.Result);
XmlReader reader = XmlReader.Create(stream);
while
(reader.Read())
{
if
(reader.NodeType == XmlNodeType.Element)
{
if
(reader.Name ==
"token"
)
{
// Store Token for Later...
api.auth.token = reader.GetAttribute(
"id"
);
// Get tenant ID to build URL's...
reader.ReadToDescendant(
"tenant"
);
string
tenant = reader.GetAttribute(
"id"
);
api.auth.tenant = tenant;
NavigationService.Navigate(
new
Uri(@
"/Overview.xaml"
, UriKind.Relative));
}
}
}
}
catch
(WebException r)
{
}
catch
{
MessageBox.Show(
"Unknown error. Please try again and check your internet connection"
);
}
}
}
}
StackTrace " at Cloud_Connect_for_Rackspace.MainPage.btnLogin_Click(Object sender, EventArgs e)
at Microsoft.Phone.Shell.ApplicationBarItemContainer.FireEventHandler(EventHandler handler, Object sender, EventArgs args)
at Microsoft.Phone.Shell.ApplicationBarIconButtonContainer.ClickEvent()
at Microsoft.Phone.Shell.ApplicationBar.OnCommand(UInt32 idCommand, Boolean isButton)
at Microsoft.Phone.Shell.Interop.NativeCallbackInteropWrapper.OnCommand(UInt32 idCommand, Boolean isButton)" string
When I check, busyidicator is returning a null reference?