Sketch your posts!

draw — Szili @ 8:56 pm

Sketchcast!

NoteToMyself: Xaml stream is null

code, silverlight — Szili @ 11:39 am

If your Xaml stream doesn’t load, chances are:

  • Your Xaml reference isn’t pointing correctly to the Xaml file.
  • Your Xaml is not valid.
  • Your Control is not set to be an Embedded Resource.
  • InitilazeFromXaml(…) is not in the lowest controls’ contructor in your inheritance tree.

NoteToMyself: Frameworkelement and System.ArgumentException

code, silverlight — Szili @ 9:06 am

Just a reminder to myself.

  • Something is wrong with the names
  • You are trying to add the Frameworkelment as a child, but it’s already a child of someone else, and you haven’t removed it.
  • It’s null.

Silverlight Loaded Event and Object Initializers

code, silverlight — Szili @ 12:38 pm

Got into a tricky situation today.

I used the new C# Object Initializer “syntactic sugar” to initialize my object:
MyType MyObject = new MyType{MyBool=true};

At the same time I used the property as a condition in MyObject.

First I used it in the constructor, but it didn’t work since the new value of the property was given only after the constructor ran (pretty logical).

Then I used it in the Loaded Event, but the event fires way after I need the changes made by MyBool.

Three things learned:

  • The Object Initializer give value to the properties after the object is instantiated.
  • I thought the Loaded event fires right after the object is instantiated. It’s not.
  • I’m still a Noob.

(The solution was to give parameters to my constructor and give value to the property through it. But this is not the important part.)

Giving value to a Point

code, silverlight — Szili @ 6:05 pm

Point class constructor problems can be caused by regional settings. Dot vs. comma stuff: http://silverlight.net/forums/t/4142.aspx

I’m still hopeless!!!

Solution 1
Can’t really call it a solution. Just inverses the problem..

double x = Convert.ToDouble("11,5");
double y = Convert.ToDouble("0,44");
Point TestPoint = new Point(x,y);

Solution 2
Didn’t really work for me either. I guess it’s my fault, but i had problem with constructing Point from results of calculations:

http://www.codeproject.com/csharp/floatparse.asp

Solution 3
My solution. It’s cool until you use it to create a new point. But as you try to give value to a Point property, like GradientOrigin it fails.

double x;
string _x = (2.0 / 3.0).ToString(System.Globalization.CultureInfo.InvariantCulture);
x = double.Parse(_x, System.Globalization.CultureInfo.InvariantCulture);
double y;
string _y = (1.0 / 2.0).ToString(System.Globalization.CultureInfo.InvariantCulture);
y = double.Parse(_y, System.Globalization.CultureInfo.InvariantCulture);
Point TestPoint = new Point(x,y);

Extensive tests with September refresh

(with no results…)

(more…)

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2010 Szili | powered by WordPress with Barecity