Im new to WPF. I have some OOP experience. What is the proper way to apply multiple transforms to a control? I want to apply a ScaleTransform and a RotateTransform to a Path I drew in Expression Blend. On the canvas, I have 2 sliders; one each to control the Rotate and Scale transforms properties. Using the sliders, I should be able to control both the scale and the angle of the Path dynamically. How you implement it would depend on how detailed your app is, but mine is simple a la hellow world. Here is how I do it:

In public MainWindow(), I create a TransformCollection, to which I add a ScaleTransform and a RotateTransform object. Then I assign this TransformCollection to a TransformGroup's Children property. Then I assign this TransformGroup to the Path's RenderTransform property. ValueChanged events for the sliders update the values in the RotateTransform and ScaleTransform references. The solution builds in Expression Blend. But when I launch the assembly, it crashes. Looking at the Results panel it says something about one of the ScaleTransform or RotateTransform references not being initialized, when I attempt to adjust the transform property in the slider ValueCHanged event.

My code is below:


public MainWindow()
{


this.InitializeComponent();
tg1 = new TransformGroup();
rt1 = new RotateTransform(0);
st1 = new ScaleTransform(1, 1);
tg1.Children = new TransformCollection(4);
tg1.Children.Add(st1);
tg1.Children.Add(rt1);
Path1.RenderTransform = tg1;
// Insert code required on object creation below this point.
}

private void Slider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e)
{
// TODO: Add event handler implementation here.

//***********************
}

private void SizeSlider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e)
{
// TODO: Add event handler implementation here.

//*************************
}




Look at the string of stars in both events. The settting of the relevant transformation property has been cut out. It seems I can set either the RotateTransform's property or the ScaleTransforms property, but not both. But when I implement the code to set both properties in both of those events, the code builds, but crashes on Launch.


Any IDea? is this even the proper way to do what Im trying to do?


Appreciate your help