Saturday, March 22, 2014

Issues with WP8_full.exe (Windows Phone SDK) causing win 8.1 crash

I have been battling this issue for the last few days.  I have done any number of fixes after trying to install the windows phone SDK onto VS 2012.  Once having successfully installed the SDK a reboot is required.  When you this the system never recovers upon reboot.  I have learned to have back up a restore point. This has helped me since I have tried any number of fixes to get this installed and working.  It is definitely an issue with the SDK install and the virtualization. 

There are a number of recommended fixes online which all revolve around issues with virtualization and the SDK.  I am trying a new wrinkle on the installation.   I have disabled the virtualization on my motherboard.  Now I am installing the SDK, and this did not fix the issue

This is an ongoing issue with a bad driver.  The HP box I am fighting with has a wifi/Bluetooth card from RALink RT_3290.  The driver I was using to upgrade to 8.1 was for 8.0.  The driver was not available from RAlink since they were bought out by MediaLink.  Once I located the correct drivers, I reinstalled the drivers and still had issues until I uninstalled the Bluetooth drivers and rebooted.


Mediatek 802.11 Wireless LAN Adapter Driver
By downloading, you agree to the terms and conditions of the HP Software License Agreement.
Type: Driver - Network
Version: 1.00 (19 Sep 2013)
Operating System(s): Microsoft Windows 8.1 (32-bit), Microsoft Windows 8.1 (64-bit)

Mediatek Bluetooth Software Driver
File name: sp63302.exe (38 MB)
Type: Driver - Network -
Version: 2.9.19.0 (22 Oct 2013)
Operating System(s): Microsoft Windows 8.1 (32-bit), Microsoft Windows 8.1 (64-bit)
File name: sp64041.exe (89 MB)

Wednesday, March 19, 2014

Weeeee fun with the ListPicker control Windows Phone

I was trying to get this control to behave.  I was using the SelectionChanged event thinking it
would behave like the trusty combo box.  This is not the case.  The ListPicker is "always on"
so it will fire when the page loads or say other events like... setting the visibility to true.
This is what bit me.  Fortunately, the solution to this is quite simple.



Solution:

    private void SomeListPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        // Make sure we don't handle the event during initiation.
        if (e.RemovedItems != null && e.RemovedItems.Count > 0)
        {
            if (this.SomeListPicker.SelectedItem != null)
            {
               // Do actual stuff.                   
            }
         }           
    }

Source:
http://samidipbasu.com/2011/05/19/fun-with-toolkit-listpicker-selections/

Windows Phone FindAncestor Control XAML

Now that my app is progressing along I have a proliferation of xaml elements on each of my screens.
I ran into the issue during an event I have the child element but I needed a reference to the parent element.  APIs exist to really ease this process.  Using the VisualTreeHelper I was able to walk the tree with this routine which I discovered in the stackoverflow forum.


XAML:
<DataTemplate x:Key="SimpleItemTemplate">
  <Button Click="Button_Click">In DataTemplate</Button>
</DataTemplate>
Code behind:
private void Button_Click(object sender, RoutedEventArgs e)
{
  Button btn = (Button)sender;
  ListBox lb = FindAncestor<ListBox>(btn);
  Debug.WriteLine(lb);
}

public static T FindAncestor<T>(DependencyObject from)
  where T : class
{
  if (from == null)
  {
    return null;
  }

  T candidate = from as T;
  if (candidate != null)
  {
    return candidate;
  }

  return FindAncestor<T>(VisualTreeHelper.GetParent(from));
}


source:
http://stackoverflow.com/questions/2633109/listboxitem-parent-returns-nothing-unable-to-get-it-thru-visualtreehelper-getpa
http://msdn.microsoft.com/en-us/library/system.windows.media.visualtreehelper.getparent(v=vs.95).aspx

XAML Rotate Image

Trying to spice up a select activity on a phone app.  I had a png image which I wanted to rotate 90'
upon selection.  Turns out that the API's for this are pretty straight forward.  I did this in the code behind wired up to the selectionchanged event.


XAML:

<Image x:Name="imgIcon" Tap="OnTap"/>


Code Behind:

OnTap(object sender, RoutedEventArgs e)
{

SelectEditIcon(imgIcon);

}

private void SelectEditIcon(Image image)
{
RotateTransform rt = new RotateTransform();
rt.Angle = 90;
image.RenderTransform = rt;
image.RenderTransformOrigin = new Point(0.5,0.5);
}


private void UnselectEditIcon(Image image)
{
RotateTransform rt = new RotateTransform();
rt.Angle = 360;
image.RenderTransform = rt;
image.RenderTransformOrigin = new Point(0.5,0.5);
}



Note:  It is important to define the point of rotation for the image if  you do not then it will not
rotate correctly.  This was done by using setting the Origin to X=0.5/ Y=0.5


source:
http://msdn.microsoft.com/en-us/library/system.windows.media.rotatetransform(v=vs.110).aspx

Friday, March 14, 2014

Screen Masking for Windows Phone 8 Textbox Control

This is a pretty common theme on google.  Given the variety of explanations which were quite interesting and thorough but not exactly what I needed.  I finally reverted back to MSDN and found
what I was looking for.  the Textbox control in Silverlight supports a property called InputScopeNameValue.  This allows one to determine the keyboard layout of the SIP (software input panel).    One just sets the property to the desired setting to control input on the textbox.

<TextBox Text="HelloWorld">
    <TextBox.InputScope>
        <InputScope>
            <InputScopeName NameValue="Url" />
        </InputScope>
    </TextBox.InputScope>
</TextBox>

SIP layoutXAML or enumeration valueSIP description
DefaultDefault, and other standard input scope valuesStandard QWERTY layout
TextTextStandard layout with features such as autocorrect and text suggestion
WebUrlStandard layout with .com and customized Enter key for typing URLs.
E-mail addressEmailSmtpAddressStandard layout with .com and @ key.
E-mail name or addressEmailNameOrAddressStandard layout with .com and @ key, and easy access to phone number layout.
MapsMapsStandard layout with a customized Enter key. Used to type a location to search for on a map
Phone numberTelephoneNumber12-key layout
SearchSearchSemi-transparent layout with a Search and .com key.
SMS contactNameOrPhoneNumberStandard layout with access to phone number layout. Used to type in the SMS To field
ChatChatText input that uses intelligent features such as abbreviations

Source:http://msdn.microsoft.com/en-us/library/ff426929(v=vs.95).aspx

XAML Listbox control

I was trying to get a windows phone control to show a horizontal scrolling picture bar.
The pictures should be picked up from the camera roll in Windows Phone 8.
This does not exist out of the box.  It took some XAML searching and programming
to get it working correctly.  Thanks to Andy_TeamG for the tip!



XAML:

<Image x:Name="Image" />

<ListBox.ItemTemplate  OnSelectionChanged="lstImages_SelectionChanged">
<DataTemplate>
<Image Source="{Binding ImageFile}" Width="100" Height="100"/>
DataTemplate>
ListBox.ItemTemplate>


Code Behind


private void GetImages()
{
MediaLibrary mediaLibrary = new MediaLibrary();
var pictures = mediaLibrary.Pictures;
foreach (var picture in pictures)
{
BitmapImage image = new BitmapImage();
image.SetSource(picture.GetImage());
MediaImage mediaImage = new MediaImage();
mediaImage.ImageFile = image;
lstImages.Items.Add(mediaImage);
}




private void lstImages_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
MediaLibrary mediaLibrary = new MediaLibrary();
BitmapImage image = new BitmapImage();
image.SetSource(mediaLibrary.Pictures[lstImages.SelectedIndex].GetImage());
imgSelectedPhoto.Source = image;
}





Source:
http://andy-teamg.blogspot.com/2010/07/windows-phone-7-selecting-device-photos.html

Thursday, March 6, 2014

Getting out of the SIP (Soft Input Panel) programmatically

I have been cranking on my first phone application and working with some basic user requirements.
I did not get to far in before I ran into this issue.  Most of the how apps just blow by the simple issue
of going from one text element to the next.  I just assumed it was like working with a web form.  Well forgot I am not working with a the benefit of a browser which defines a lot of this default behavior. 

The text box control will display the SIP as soon as you focus on it.  The issue is when you want to leave the textbox.  The return key and tab key will not kick you back out to the page level.  You need to handle the event Keyup or LostFocus.


XAML

<TextBox Name="Input" KeyUp="Input_KeyUp" LostFocus="Input_KeyUp"  FontSize="40"></TextBox>
 
C# Code Behind

private void Input_KeyUp(object sender, KeyEventArgs e){ if (e.Key == Key.Enter) { this.Focus(); }}


The call to the main page will return the focus from the current textbox back to the phoneapplicationpage. 


Source:
http://blogs.msdn.com/b/silverlight_sdk/archive/2010/07/02/programmatically-dismiss-the-sip-keyboard-in-windows-phone-silverlight-app.aspx