Tuesday, May 31, 2011

UniCode in XAML

A friend asked how to put a unicode into a Textblock from codebehind today.

After a bit of research I discovered it was quite easy;

string unicodeString = "This string contains the unicode character Pi (\u03a0)";

Just swap out the #x of you code for \u and you'll get your unicode character.

Friday, February 4, 2011

Problem Steps Recorder

Cool discovery today thanks to one of the guys at work.

A tool provided out of the box with Windows 7 (professional and up) is called Problem Steps Recorder, or PSR.exe

To run the tool click the Start Orb then type PSR and you should see PSR.exe show up. Click that and you will see a small window open with some buttons.

Using this tool you can record a session, add some comments (key presses are not recorded) and then when you click Stop record it will ask you to save the session to a zip file. This file will contain a .mht file which is a single archive file of a web page. You can get the user to email this zip file to you (theres a menu option in the tool to do this) and you can then see a number of screenshots taken in sequence during the record session. Brilliant way to document an issue!

Tuesday, December 21, 2010

unsafe code in .Net

I was having an issue with a binding being overwritten and due to the complexity of the code in question was having a tough time seeing what was going on. I had a number of instances of a nested class being created which was the target of the binding. I needed to prove to myself that the local variable being queried was different to the one being set so I thought to myself, storing the memory address of the variable would be a good way to do this.

fun stuff but eventually I figured out how to do exactly that.

under properties of project on build tab theres a "allow unsafe code" checkbox.
then this snippet will compile


private unsafe string GetMemoryAddress()
{
fixed (int* ptr = &m_columnRow)
{
IntPtr addr = (IntPtr)ptr;
return addr.ToString();
}
}


the fixed command stops the GC from moving your variable so the address won't change on you later.

Thursday, July 8, 2010

Could not load file or assembly

One of the guys hit this strange problem all of a sudden. I'm not sure what changed but it seemed isolated to his machine.

Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

We removed the silverlight application and the problem remained, it seemed to be something trying to reference the silverlight assembly outside of the silverlight project.

The workaround was to add the System.Windows.dll to the GAC by using the gacutil command line tool from the Visual Studio Command line. (make sure you run it as administrator).

The command was:
gacutil /i "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.dll"

After that it all worked normally. If anyone knows what specifically caused this please let me know.

Friday, January 8, 2010

DataGrid limitation

This week I hit a limitation in the Silverlight DataGrid control. I'm hoping it's just something I've not learned yet with bindings but it does appear that the simplest solution is to display the data in a different manner.

Problem: The data I'm trying to display is essentially a collection of collections of some object. So the rows can be any number, normal for a datagrid, and the columns are also any number. That's not so normal for a datagrid. Usually you have a set number of columns and your rows vary.

Solution: I tried adding columns to the datagrid dynamically, and while this worked just fine (adding them in codebehind) the real issue I hit was how to bind to the underlaying objects. The data is being built dynamically and I tried a couple of formats. I tried a collection of Arrays, and also an ObservableCollection of ObservableCollections. I could bind to the objects but as Bindings in Silverlight have to bind to properties I couldn't come up with a solution presenting the data this way.

My solution as a result has been to display the data in a more traditional manner, with a lists and a datagrid. When you select an item in the list it repopulates the data in the datagrid to show the objects.

If anyone comes across a way to bind a datagrid cell to a collection of collections please let me know.

Friday, December 18, 2009

Silverlight Xmas meetup

This month, I was toying with not actually having a meeting due to how close to Christmas the normal date falls.

My laptop has failed and I've been flat out with work. However, the room has been booked and I thought it would still be cool to meet up and chat about the newly launched Silverlight 4 beta, and have some Christmas drinks.

TOPIC: Christmas Drinks plus Silverlight 4 beta cheer
DATE: Wednesday, December 23rd, 6:00pm
VENUE: 43Below. 43 Barrack Street, Perth
COST: Free. All welcome

Be great to catch up.

Failed laptop

Ouch. My Dell m1730 which has served me fairly faithfully for the last 18+ months has died. The graphics card has always run really hot and it killed the battery some time ago. I replaced the battery (not knowing it was most likely the exessive heat) a few months ago.

My machine hung a few times and so I logged a call with Dell. they came and replaced the motherboard which is when the technician noticed the heat of the graphics card. 6 weeks later they replaced the graphics card. That was yesterday.. The technician left and one reboot later the machine would not boot. It would sit at 80% on the BIOS screen. I couldnt even get into the BIOS. So I called Dell and asked for my old graphics card back and the answer was no. ow!

The replacement graphics card is due in February which is probably another 6 week wait. I use this thing for work so that's not good for me. The option given to me by Dell was to replace the whole machine. I have a mate who had 7 faults in 9 months with this machine and they gave him an Alienware M17x of equal specs so that would be an excellent alternative for me.

Would be nice if I could add a few extras to it but I suspect they will choose the specs (equal or greater specs I was told). Thanks Dell!
My thought on Dell's is they are pretty good, but always get as much warranty as you can because faults can become very expensive. Lifetime of a laptop is 2 years for me so more than that is a bonus. I always get 3 years of cover.

Will let you know what I end up with.