You must Sign In to post a response.
  • Category: Silverlight

    How to change XAML to code behind?


    Are you looking for information on XAML? Want to know how to change XAML to code behind? Read this thread to learn more about XAML examples.



    Sir,

    I want to write this in code behind.



    <StackPanel x:Name="LayoutRoot6" Margin="700,150,-680,-120" Width="110" MouseLeave="textBlock1_MouseLeave" Canvas.ZIndex="2">>
    <StackPanel.Resources>
    <Storyboard x:Name="reversehelp">
    <DoubleAnimation From="150" To="0" Duration="00:00:1" Storyboard.TargetName="canvashelp" Storyboard.TargetProperty="Height">
    <DoubleAnimation.EasingFunction>
    <BounceEase EasingMode="EaseIn" />
    </DoubleAnimation.EasingFunction>
    </DoubleAnimation>
    <DoubleAnimation From="18" To="0" Duration="00:00:2" Storyboard.TargetName="Faqslink" Storyboard.TargetProperty="Height">
    </DoubleAnimation>
    <DoubleAnimation From="18" To="0" Duration="00:00:2" Storyboard.TargetName="processlink" Storyboard.TargetProperty="Height">
    </DoubleAnimation>
    <DoubleAnimation From="18" To="0" Duration="00:00:2" Storyboard.TargetName="userlink" Storyboard.TargetProperty="Height">
    </DoubleAnimation>
    </Storyboard>
    <Storyboard x:Name="helpstoryboard">
    <DoubleAnimation From="0" To="150" Duration="00:00:1" Storyboard.TargetName="canvashelp" Storyboard.TargetProperty="Height">
    <DoubleAnimation.EasingFunction>
    <BounceEase EasingMode="EaseOut" />
    </DoubleAnimation.EasingFunction>
    </DoubleAnimation>
    <DoubleAnimation From="0" To="18" Duration="00:00:1" Storyboard.TargetName="Faqslink" Storyboard.TargetProperty="Height">
    </DoubleAnimation>
    <DoubleAnimation From="0" To="18" Duration="00:00:1" Storyboard.TargetName="processlink" Storyboard.TargetProperty="Height">
    </DoubleAnimation>
    <DoubleAnimation From="0" To="18" Duration="00:00:1" Storyboard.TargetName="userlink" Storyboard.TargetProperty="Height">
    </DoubleAnimation>
    <DoubleAnimation From="100" To="216" Duration="00:00:0" Storyboard.TargetName="stackform" Storyboard.TargetProperty="Width">
    </DoubleAnimation>
    </Storyboard>
    </StackPanel.Resources>
    <TextBlock Height="23" Name="txtform" Text="Help" Foreground="Blue" Width="100" Margin="40,0,20,20"/>

    <Canvas Width="85" Visibility="Collapsed" Height="93" Margin="-25,0,0,0" x:Name="canvashelp" Background="#8e8e8e">
    <HyperlinkButton Canvas.Left="8" Canvas.Top="23" Foreground="White" Content="FAQs" Height="0" x:Name="Faqslink"></HyperlinkButton>
    <HyperlinkButton Canvas.Left="8" Canvas.Top="46" Foreground="White" Content="Process Flow" Height="0" x:Name="processlink"></HyperlinkButton>
    <HyperlinkButton Canvas.Left="7" Canvas.Top="68" Foreground="White" Content="User Manual" Height="0" x:Name="userlink"></HyperlinkButton>
    </Canvas>

    </StackPanel>

    Please Help me out.

    MKS
  • #720221
    This might be helpful:

    StackPanel sp = new StackPanel();
    sp.Margin.Top = 700;
    sp.Margin.Right = 150;
    sp.Margin.Bottom = -680;
    sp.Margin.Left = -120;
    sp.Width = 110;
    sp.MouseLeave += new MouseEventHandler(textBlock1_MouseLeave);

    Storyboard str = new Storyboard();
    DoubleAnimation db1 = new DoubleAnimation();
    db1.From = 150;
    db1.To = 0;
    db1.Duration = new Duration(TimeSpan.FromSeconds(01));
    Storyboard.SetTarget(db1,canvashelp);
    Storyboard.SetTargetProperty(db1, Height);
    str.Children.Add(db1);

    DoubleAnimation db2 = new DoubleAnimation();
    db2.From = 18;
    db2.To = 0;
    db2.Duration = new Duration(TimeSpan.FromSeconds(01));
    Storyboard.SetTarget(db2, Faqslink);
    Storyboard.SetTargetProperty(db2, Height);
    str.Children.Add(db2);

    In this way you can add multiple DoubleAnimation part.

    TextBlock txb = new TextBlock();
    txb.Height = 23;
    txb.Text = "Help";
    txb.Width = 100;
    txb.Margin.Top = 40;
    txb.Margin.Right = 0;
    txb.Margin.Bottom = 20;
    txb.Margin.Left = 20;
    sp.Children.Add(txb);
    like above can add hyperlink, canvas etc in stackpanel.

    Thanks


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.