Archive

Archive for December, 2012

WinRT Objects in the Windows Phone 8 Designer

December 19, 2012 Leave a comment

It is possible to create User Controls for Windows Phone Apps which make use of Windows Phone Runtime types. These WinRT types can’t be loaded inside the designer process. As a consequence, if a User Control has WinRT objects that it tries to load during design time, an error occurs. In both Blend and Visual Studio, the artboard will show an error where the control is with the message “Cannot create an instance of ‘<Control Type>’”.

Cannot create an instance of "ControlWithRtComponent"

To have an improved design experience with this User Control, the author of the control can use DesignerProperties.IsInDesignTool to know if the WinRT types should be instantiated. The code behind the User Control may look something like:

if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
{
wprc = new WindowsPhoneRuntimeComponent();
}

With this code inside of the User Control, the WinRT object will be prevented from being loaded when the control is instantiated within Blend. The User Control author can have the control show a default, static image in its place.

Using IsInDesignTool, User Control developers can create designer appearances for their controls, so that app developers can use their controls in either Visual Studio or Blend for Visual Studio when developing new Windows Phone 8 apps.

Get fake directory names to stay away

December 17, 2012 Leave a comment

Previously I posted Getting rid of fake directory names in Windows 7 talking about how to clear the LocalizedResourceName from a user profile, so that way the name of directories in Explorer match the names you’d see in other programs. Certain Windows updates will put the fake directory names back. I have gotten annoyed at periodically clearing the names, so I created a PowerShell script to automatically do it.

$parentDirs= ($env:USERPROFILE,$env:PUBLIC)
foreach ($parentDir in $parentDirs){
$dirs = Get-Item ($parentDir+“\*”);
foreach($dir in $dirs){
try{
$filename = ($dir.FullName +“\desktop.ini”)
$content = Get-Content $filename -ErrorAction Stop;
$newContent = $content | Where-Object {-Not $_.StartsWith(“LocalizedResourceName”)};
if($newContent.Length -lt $content.Length){
Set-Content $filename -Value $newContent
}
}
catch [System.Management.Automation.ItemNotFoundException]{ continue; }
}
}

To run the script when I log in I created a Scheduled Task. In my Task Scheduler Library I created a task which runs when I log in and has an action of running C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe with the arguments -NonInteractive -File “C:\Users\Public\Documents\RemoveLocName.ps1”.

Now I don’t need to worry about incorrect names being displayed again.

Busy Day

December 13, 2012 Leave a comment

I’ve had quite the busy day. I didn’t even make it into work. First I waited for a package, then I went to the bank to deposit a check, then I went to the dentist, then I returned some medical equipment, next was putting new tires on the car followed by a haircut. I then went back home, had lunch, distracted my son for about an hour and took one package to the Post and another to the UPS store. After that I went to the charity deposit trailer and dropped some stuff off. By the time I was done with all of that it was 4 pm, and my son was waking up from his nap. I sure had a lot to do for a Thursday.

Categories: Organizations