Windows 8 >> More Info

Lista de Problemas e Correções

1. Fix using statements in C# files.
Lots of namespace names have changed. Here is a list of .NET assemblies and their WinRT counterparts. Visual Studio Intellisense and right-click+Resolve helps you with these issues.
Old: using System.Windows;
New: using Window.UI.Xaml;
Old: using System.Windows.Controls
New: Windows.UI.Xaml.Controls
2. Fix references to namespaces in XAML files
Old: xmlns:local=”clr-namespace:Saveman”
New: xmlns:local=”using:Saveman”
3. Some assemblies no longer apply.
Old: xmlns:ic=”clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions”
4. PhoneApplicationPage doesn’t apply:
Old: <phone:PhoneApplicationPage
    SupportedOrientations=”Landscape” Orientation=”Landscape”
New: <Page>

5. Static phone resources are not applicable. Remove or replace as applicable.
Old: FontFamily=”{StaticResource PhoneFontFamilyNormal}” FontSize=”{StaticResource PhoneFontSizeNormal}” Foreground=”{StaticResource PhoneForegroundBrush}”
6. No RadialGradientBrush (Substitute LinearGradientBrush?)
7. Accessibility of named XAML elements in a UserControl is now private. Previously, you could reach deep into included UserControls’ named elements. I personally think this is a welcome change.
8. Mouse events are replaced with pointer events.
Old: MouseLeftButtonDown=”UserControl_MouseLeftButtonDown”
New: PointerPressed=”UserControl_PointerPressed”
Old: this.myControl.MouseLeftButtonDown += new MouseButtonEventHandler(UserControl_MouseLeftButtonDown);
New: this.myControl.PointerPressed += UserControl_PointerPressed;
Old: private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
New: private void UserControl_PointerPressed(object sender, PointerEventArgs e)
9. StoryBoard completed event signature has changed
Old: this.myAnim.Completed += new EventHandler(myAnim_Completed);
New: this.myAnim.Completed += myAnim_Completed;
Old: void myAnim_Completed(object sender, EventArgs e)
New: void myAnim_Completed(object sender, object e)
10. VisualStateGroup.States is now a generic list.
Old: IList StatesList = this.VisualStateGroup.States;
New: IList<VisualState> = this.VisualStateGroup.States;
Old: IEnumerator enumerator = StatesList.GetEnumerator();
New: IEnumerator<VisualState> enumerator = StatesList.GetEnumerator();
11. HyperlinkButton control has no TargetName property, or NavigateUri method.
12. Removed embedded fonts. I removed the following: FontFamily=”/Saveman;component/Fonts/ Font”
13. Removed the Microsoft Advertising component (e.g: ad:AdContol) to be replaced with the Win8 version later.
14. Removed clipping from UIElement controls: Example: <Grid Clip=”M0,0L1038,0 1038,148 0,148z”/>
15. string.Contains(char) is absent
Old: string.Contains(myCharVariable)
New: string.Contains(myCharVariable.ToString())
16. PropertyPath is absent. It appears to be no longer needed.
Old: Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(“(UIElement.RenderTransform).(CompositeTransform.TranslateX)”));
New: Storyboard.SetTargetProperty(myDoubleAnimation, “(UIElement.RenderTransform).(CompositeTransform.TranslateX)”);
17: Windows.UI.Xaml.Controls.TextBox doesn’t support some properties of System.Windows.Controls.TextBox. Examples: SelectionBackground, SelectionForeground, InputScope
18. Windows.UI.Xaml.Controls.Control has no Focus() method.
19. System.Windows.Input.UI.Key class is replaced with Windows.System.VirtualKey
20. System.ComponentModel.BackgroundWorker needs to be replaced with async methods
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler();
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
private void worker_DoWork(object sender, DoWorkEventArgs e)
MyData myData = (MyData)e.Argument;
// Time consuming task
private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
// Completion task
private async void DoWorkAsync(NewRoundData data)
var response = await Task<string>.Factory.StartNew(() =>
// Time consuming task (data is still accessible here)
return “ok”;
// Completion task (data is still accessible here)
21. Windows.UI.Xaml.Application has no GetResourceStream() method.(System.Windows.Resources.StreamResourceInfo is not needed). You can use the new, asynchronous, StorageFile API.
private void InitializeDictionary()
    String ResourceReference = “/Saveman;component/Other/Words.txt”
    StreamResourceInfo sri = Application.GetResourceStream(new Uri(ResourceReference, UriKind.Relative));
    StreamReader sr = new StreamReader(sri.Stream);
    while (!sr.EndOfStream)
        string str = sr.ReadLine();
private async void InitializeDictionary()
    String ResourceReference = “ms-appx:///Other/Words.txt”;
    StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(ResourceReference, UriKind.Absolute));
    Stream sr = await file.OpenStreamForReadAsync();
    this.Words = await FileIO.ReadLinesAsync(file);
22. Debug.Assert has no overload that takes 3 arguments.
Old: Debug.Assert(false, “Unexpected command from input dialog”, Enum.GetName(typeof(Commands), args.Command));
New: Debug.Assert(false, string.format(“Unexpected command from input dialog {0} {1}”, Enum.GetName(typeof(Commands), args.Command)));
23. IsolatedStorageSettings is not applicable. In WinRT you have regular storage functions. For now, substitute a regular dictionary.
Old: private static IsolatedStorageSettings userSettings = IsolatedStorageSettings.ApplicationSettings;
New: private static Dictionary<string, object> userSettings = new Dictionary<string, object>();
24. Declaring a using statement appears to be required for types not in the current file even if the code is already in that namespace.
New: using Saveman;

Bugs no VS 2011 Beta?

1. Symptom
: Error message: “The member XXX is not recognized or is not accessible” appears even if the member is known to be an immediate public property on the element. 
Workaround: It will go away if you close the XAML file in Visual Studio (and come back if you open it).
2. Symptom: Intellisense stops working. Right-click->Resolve is no longer there. Solution Explorer does not show any references (even though they should be there automatically)
Workaround: Exclude problematic files in the project (to narrow down the problem that causes the issue) and/or restart Visual Studio
3. Symptom: “Unable to cast COM object of type ‘XXX’ to class type ‘XXX’. Instances of types that represent COM components cannot be case to different types that represent COM components; however they can be case to interfaces as long as the undelying COM component supports QueryInterface calls for the IID of the interface.
Workaround: There may be stale files that are confusing Visual Studio. Clean Project. Go into the project folder and delete the obj and bin folders. Rebuild.