Silverlight CustomControls and Blend 2 |
Most of you would have probably stopped developing in silverlight 1.1 2.0 after seeing how custom controls worked in blend 2 (they do nothing). But for those of you who persevered some tips to help you on your way.
Xaml
The current control model is absolutely unfinished. One of the firts thins you have to do is change the way a CustomControl is loaded, and map the controls in your xaml to your code.
System.IO.Stream s =
this.GetType().Assembly.GetManifestResourceStream(“UserControl1.xaml”);
FrameworkElement _actualControl = this.InitializeFromXaml(
new System.IO.StreamReader(s).ReadToEnd()
);
_actualControl.FindName(“Button”);Namespaces
Blend 2 doesn’t understand it when you put namespaces in your customcontrol xaml, it does work in the xmlns decleration but not in the actual xaml control.
Wrong:
<CustomControls: Buttons.RoundButton …..=“” /> and
<CustomControls.Buttons: RoundButton …..=“” />
Right:
<CustomControls:RoundButton …..=“” />
Visual Containers
Because custom controls do not show in blend 2, making layouts is a very dificult story. One solution is to create rectangles for every custom control and name them the same except for a temp_ prefix.
Then in the onloaded event of your page, cycle trough your object tree and place the custom controls over the rectangles and remove them.
More to come.
Robertjan Tuit
Categories : UI, Silverlight, C#


But as could be expected after the release of the new c# 3.0 language features, there is a “newcomer in mocking town” and it’s named Moq, pronounced as “Mock-You”.













RSS English
RSS Nederlands





