Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Please help, I'm trying to create wpf Ojects dynamically using code.
I'm running into an issue when I try to add an animation, in my example to a Button. This is a custom animation. Look towards the bottom of the code where it says:
XML
"<local:clEffects x:Name='myclEffects' x:Name='myclEffects'/>

XML
            "<RowDefinition Height='107*'/>" &
        "</Grid.RowDefinitions>" &
        "<StackPanel Orientation='Horizontal' TextElement.FontWeight='Bold' TextElement.FontSize='72pt' Margin='2,-3,163,0' Height='177' VerticalAlignment='Top'>" &
            "<StackPanel.Resources>" &
                "<Storyboard x:Name='myStoryboard' x:Key='myFold'>" &
                    "<DoubleAnimation Storyboard.TargetProperty='clEffects.Left' Storyboard.TargetName='mysbLeft' " &
                    "/>" &
                    "</Storyboard>" &
                    "<Storyboard x:Name='myStoryboard2' x:Key='myDropShadow'>" &
                    "<DoubleAnimation Storyboard.TargetProperty='ShadowDepth' Storyboard.TargetName='mysbDropShadow'" &
                    "/>" &
                "</Storyboard>" &
            "</StackPanel.Resources>" &
            "<Button x:Name='myButton1' Content='Click!' Width='91' " &
                "Margin='60' Height='42' FontSize='24' Padding='1'>" &
                    "<Button.Effect>" &
                    "<local:clEffects x:Name='myclEffects' x:Name='myclEffects'/>" &
                    "</Button.Effect>" &
                "</Button>" &
            "</StackPanel>" &
"</Grid>"

VB
        Dim stringReader As New StringReader(xaml)
        Dim xmlReader_1 As XmlReader = XmlReader.Create(stringReader)
        Dim tree As UIElement = DirectCast(XamlReader.Load(xmlReader_1), UIElement)
        LayoutRoot.Children.Add(tree)

End Sub


Thank you for your help.

[edit]Code block move to around the code... - OriginalGriff[/edit]
Posted
Updated 13-Feb-11 8:13am
v4
Comments
Manfred Rudolf Bihy 13-Feb-11 16:59pm    
Cleaned up your non answers. Please post those as comments.

This is what I generally do to debug dynamic xaml.

Put a break point at Dim xmlReader_1 As XmlReader = XmlReader.Create(stringReader).
Copy the text inside stringReader into an existing xaml and then check it.

It may help you get to the root of the problem.
 
Share this answer
 
I don't see where you've added the namespace reference to local. Perhaps you meant to, but then forgot?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900