Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums

Go Back   Vista Forums > Vista technology newsgroups > Avalon

Binding to properties of a user control

Reply
 
Thread Tools Display Modes
Old 02-17-2008   #1
Dave
Guest
 
Posts: n/a

Binding to properties of a user control

Just getting up to speed with WPF...

I've got a simple user control:

<UserControl x:Class="WpfApplication2.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<Button>Hello, world</Button>
</UserControl>

And I want to apply a transform to this when it is instantiated and
bind the animation to the transform:

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication2.Window1"
Title="Window1" xmlns:d="http://schemas.microsoft.com/expression/
blend/2006"
xmlns:my="clr-namespace:WpfApplication2">

<StackPanel>
<my:MyUserControl>
<my:MyUserControl.RenderTransform>
<TranslateTransform x:Name="MyTransform" X="10"/>
</my:MyUserControl.RenderTransform>

<my:MyUserControl.Triggers>
<EventTrigger RoutedEvent="Button.Click" >
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="MyTransform" Storyboard.TargetProperty="X"
IsCumulative="True" By="100"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</my:MyUserControl.Triggers>

</my:MyUserControl>
</StackPanel>
</Window>

Doesn't compile.

error MC3093: Cannot set Name attribute value 'MyTransform' on element
'TranslateTransform'. 'TranslateTransform' is under the scope of
element 'MyUserControl', which already had a name registered when it
was defined in another scope. Line 11 Position 37.

Any ideas?
  Reply With Quote

Old 04-10-2008   #2
Alexey Yakovlev
Guest
 
Posts: n/a

RE: Binding to properties of a user control

Hi Dave!
Did you find any workaround for this?


  Reply With Quote
 
Reply

Thread Tools
Display Modes









Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48