PDC09 Day 1 – Dynamics in C# 4

Tuesday, November 17, 2009

Switched to the Dynamics in C# 4 session. This session hall is not full at all… I’d rather say it is pretty empty… Probably this session is for real technology geeks like me :)   Did you know, that you cold create your own dynamic object by deriving from DynamicObject base class? class Program { static void Main(string args) { dynamic d = new myDynamic(); Console.WriteLine(d++); } } class myDynamic : DynamicObject { public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result) { Console.WriteLine(binder.Operation); ...

Silverlight Quick Tip: Dynamically Updating Class Fields/Properties

Thursday, August 27, 2009

In previous post (here) I blogged about displaying values of class/control in runtime and displaying them in Visual Studio - like property window. Today I’ll show how to push them back to the class instance. In previous post I’ve stored values in “ObservableCollection<FieldsPropertiesData>” for easy databinding and connected this ListBox control. In order to get user input I’ve created TwoWay databinding in DataTemplate – here is updated data template: <Style TargetType="local:FiledPropertyData"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:FiledPropertyData"> <Grid ToolTipService.Placement="Mouse" Width="{TemplateBinding Width}"> ...

Silverlight Quick Tip: Dynamically Displaying Class Fields/Properties

Thursday, August 13, 2009

In one of my projects I had to create something like Visual Studio property window, for data set of different controls/data classes. Those controls/classes are still under development and I needed the way to display/change values of those properties dynamically without even knowing what is inside. For the simple case, let’s assume the following class which holds the data: public class SampleData { public SampleData() { BooleanProperty = false; } public string StringProperty { get; set; } public bool BooleanProperty { get; set; } public Button ButtonProperty { get;...

Silverlight Tip: Object Creation via Silverlight.js – IE8 & FireFox tweak

Friday, May 1, 2009

Yesterday, when I arrive to the office my colleague (same one from this post) waited for me at the entry with new question/problem. That’s what I heard: - Hi Alex. I have a problem with my Silverlight application under FireFox – it is not being displayed on page! In IE(7) everything works fine, and in the FF is event not shown… :( - Well – I said – let’s see… I’ve got the sources from the company source server, launched the application on my machine IE(8) and got very “wired” sized application and on...

Silverlight Tip: Dynamic animations

Tuesday, January 6, 2009

Hello, I was asked about creation of animations dynamically for various elements. Today I’ll show how to create such animations for any (almost) Silverlight element. I’ll create some of popular standard PowerPoint animations. I know that it is not the full set of animations available in PowerPoint, also the animations itself are probably not perfect but it is a good starting point to those who want to know how to do it. Generally, to create the animation on-the-fly we need to create a storyboard, add one or more animations to it, add the created storyboard to...

Silverlight Tip: How to Inject and Execute JavaScript Function(s) on-the-fly from Silverlight

Thursday, December 4, 2008

Today I’ve been asked by colleague how to inject and execute JavaScript functionality from Silverlight application to the HTML DOM of hosting page. Well, things are pretty easy. First we need to get JavaScript from somewhere. In colleague's case it was an embedded resource, in my sample I’ll use TextBox to accept the script code. Also I’ll accept function name and parameters from UI. From here we have two approaches: to Eval the function code or to create “Script” element dynamically. First approach is very straightforward: ...

Quick Silverlight Tip: Define control style dynamically

Tuesday, September 9, 2008

Lately I've been asked a couple of time by client how to provide certain level of customization for their Silverlight application. In many cases they want to provide their client with ability to change styles/templates in application or part of it. Another common request, is to provide an ability to use external style definitions. Here the quick tip on how it could be achieved. I'll build really simple solution, which uses WebService to provide external style definition as loose XAML file and will apply it to XAML object. Also, my simple solution will receive some style definition as a...

Quick Silverlight Tip: Creating/Destroying Silverlight 2 Object dynamically

Tuesday, August 5, 2008

One of my clients asked me how to create and show (and then destroy) Silverlight application on the fly. Here is very fast solution, which allows such an object to be created and destroyed. First, we (still) need to have some DIV which will hold the object. Here is my sample page HTML: 1: <body> 2: <!-- Runtime errors from Silverlight will be displayed here. 3: This will contain debugging information and should be removed or hidden when debugging is completed --> ...