Dashed line in Xaml
Maybe I’m the last one on Earth figuring this out, but here it is:
<Path StrokeDashArray=”1,1″ …
More on the StrokeDashArray and creating dashed line from code here.
Maybe I’m the last one on Earth figuring this out, but here it is:
<Path StrokeDashArray=”1,1″ …
More on the StrokeDashArray and creating dashed line from code here.
The clash between decimal separators, double values and application culture already made Point type a victim. Today I found abound another one..
I had an iframe positioned above my silverlight control. Its dimensions was controlled from C# managed code (with the use of System.Windows.Browser library).
Or at least it should have been.
ERROR:
No matter I gave the right double values to set the iframe’s width, it just didn’t changed:
Iframe.SetStyleAttribute("width", value.ToString() + "px");
SOLUTION:
After a few rounds of debugging I found the solution. The problem was caused by the decimal separator being a comma instead of a point.
The fix is the same as with the Point type:
Iframe.SetStyleAttribute("width", value.ToString(System.Globalization.CultureInfo.InvariantCulture) + “px”);
Okay, I like Blend 2, but it has its tricks..
A control’s xaml when was loaded in its constructor threw a Catastrophic failure.
I designed the control in Blend 2 without touching the xaml’s source. It was a pretty simple graphic, four rectangles in a canvas.
All had unique names so the problem wasn’t related to namescopes.
To cut a long story short it occurred to me, that one rectangle had three spaces after the value in its height property. Fixing this solved the problem.
The full Exception info after the jump.
I’m working on an application with the ability to upload and run Silverlight 1.1 gadgets. This means my program needs to be able to load assemblies in run-time.
After several tests and an e-mail exchange with an MS Evangelist it seams like it’s impossible.
UPDATE: Here is how I managed to do it. The trick is that the xaml downloads and loads its assembly automatically.
void DownloadXamlFile()
{
GadgetXamlDownloader.Completed += new EventHandler(GadgetXamlDownloader_Completed);
GadgetXamlDownloader.Open(“GET”, new Uri(“./Gadgets/TestGadget/Page.xaml”, UriKind.Relative));
GadgetXamlDownloader.Send();
}
void GadgetXamlDownloader_Completed(object sender, EventArgs e)
{
ObjectFromXamlString(GadgetXamlDownloader.ResponseText);
}
void ObjectFromXamlString(string XamlString)
{
DependencyObject Gadget = XamlReader.Load(XamlString,true); //Namescoping is turned on
Gadget.SetValue(Canvas.TopProperty,this.Height/2-(Gadget as Canvas).Height/2);
Gadget.SetValue(Canvas.LeftProperty, this.Width / 2 - (Gadget as Canvas).Width / 2);
this.Children.Add(Gadget as Visual);
}
My old failed tests after the jump, they might be useful.
Grab and throw the monkeys before they reach the paintings!
My friend and I wrote this Silverlight game for an MS competition.
Check out the game here:
http://www.szili.net/sourc
And if you like it please vote for it:
http://www.flickr.com/phot
PS. The source code will be available next week.
UPDATE1: There seams to be a problem with the Silverlight Streaming service. I will check the code as fast as I can.
UPDATE2: Streaming had a short hick up but it seams ok now.
UPDATE3: The source. A junk and in Hungarian. There will be an Update4 with a polished English version with comments and stuff..
If your Xaml stream doesn’t load, chances are:
Just a reminder to myself.
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 solution was to give parameters to my constructor and give value to the property through it. But this is not the important part.)
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 1Can’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 3My 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…)