Click here to Skip to main content
15,908,455 members
Home / Discussions / C#
   

C#

 
QuestionHow to Check Data for data existence in database using C# Pin
Tej_dev27-Jun-17 8:23
Tej_dev27-Jun-17 8:23 
AnswerRe: How to Check Data for data existence in database using C# Pin
Mycroft Holmes27-Jun-17 19:32
professionalMycroft Holmes27-Jun-17 19:32 
AnswerRe: How to Check Data for data existence in database using C# Pin
jschell28-Jun-17 6:03
jschell28-Jun-17 6:03 
GeneralRe: How to Check Data for data existence in database using C# Pin
Tej_dev28-Jun-17 9:20
Tej_dev28-Jun-17 9:20 
GeneralRe: How to Check Data for data existence in database using C# Pin
Pete O'Hanlon28-Jun-17 10:44
mvePete O'Hanlon28-Jun-17 10:44 
GeneralRe: How to Check Data for data existence in database using C# Pin
Tej_dev29-Jun-17 4:51
Tej_dev29-Jun-17 4:51 
GeneralRe: How to Check Data for data existence in database using C# Pin
Pete O'Hanlon29-Jun-17 4:55
mvePete O'Hanlon29-Jun-17 4:55 
GeneralRe: How to Check Data for data existence in database using C# Pin
jschell2-Jul-17 7:10
jschell2-Jul-17 7:10 
QuestionRegex uppercase Pin
Farhad Eft27-Jun-17 0:00
Farhad Eft27-Jun-17 0:00 
QuestionRe: Regex uppercase Pin
Richard MacCutchan27-Jun-17 0:46
mveRichard MacCutchan27-Jun-17 0:46 
AnswerRe: Regex uppercase Pin
Pete O'Hanlon27-Jun-17 0:48
mvePete O'Hanlon27-Jun-17 0:48 
GeneralRe: Regex uppercase Pin
Farhad Eft27-Jun-17 0:54
Farhad Eft27-Jun-17 0:54 
GeneralRe: Regex uppercase Pin
Pete O'Hanlon27-Jun-17 1:12
mvePete O'Hanlon27-Jun-17 1:12 
QuestionPrinting multiple files of different format in ASP.Net Pin
BinodKumar7524-Jun-17 20:27
BinodKumar7524-Jun-17 20:27 
AnswerRe: Printing multiple files of different format in ASP.Net Pin
Richard MacCutchan24-Jun-17 21:17
mveRichard MacCutchan24-Jun-17 21:17 
AnswerRe: Printing multiple files of different format in ASP.Net Pin
Pete O'Hanlon25-Jun-17 6:21
mvePete O'Hanlon25-Jun-17 6:21 
QuestionHow sum for groups in grand total in crystal report. Pin
Member 1323835124-Jun-17 20:08
Member 1323835124-Jun-17 20:08 
QuestionVSTS Unit Test Pin
Rakesh Rajendra Patil23-Jun-17 20:08
Rakesh Rajendra Patil23-Jun-17 20:08 
QuestionProgrammatically Animating a StackPanel using C# in WPF Pin
Member 1322493123-Jun-17 5:20
Member 1322493123-Jun-17 5:20 
I'm writing a C# WPF application that contains two stacked StackPanels. When the user clicks on Panel1 it's height value changes expanding the space between Panel1 and Panel2. When the user clicks on Panel2 it's height is expanded and Panel1's height is set back to it's original value. I am able to get this working in the xaml code:

<pre>        <StackPanel Margin="1,1,1,1" Grid.ColumnSpan="3">
            <StackPanel Name="Panel1" Height="26">
                <Label HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="Menu_1" Foreground="White" FontWeight="Bold" MouseLeftButtonUp="Panel1_MouseLeftButtonUp">
                    <Label.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FF80CEF3" Offset="0.01"/>
                            <GradientStop Color="#FF5588A0" Offset="1"/>
                        </LinearGradientBrush>
                    </Label.Background>
                </Label>
                <StackPanel.Triggers>
                    <EventTrigger RoutedEvent="UIElement.MouseLeftButtonUp">
                        <BeginStoryboard >
                            <Storyboard x:Name="Animation1">
                                <DoubleAnimation Storyboard.TargetName="Panel1" Storyboard.TargetProperty="Height" To="646" Duration="0:0:0.50" AccelerationRatio="0.6" DecelerationRatio="0.4" />
                                <DoubleAnimation Storyboard.TargetName="Panel2" Storyboard.TargetProperty="Height" To="26" Duration="0:0:0.50" AccelerationRatio="0.6" DecelerationRatio="0.4" />
                             </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </StackPanel.Triggers>
            </StackPanel>
            <StackPanel Name="Panel2" Height="26">
                <Label HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="Menu_2" Foreground="White" FontWeight="Bold">
                    <Label.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FF80CEF3" Offset="0.01"/>
                            <GradientStop Color="#FF5588A0" Offset="1"/>
                        </LinearGradientBrush>
                    </Label.Background>
                </Label>
                <StackPanel.Triggers>
                    <EventTrigger RoutedEvent="UIElement.MouseLeftButtonUp">
                        <BeginStoryboard>
                            <Storyboard x:Name="menu">
                                <DoubleAnimation x:Name="Menu_1" Storyboard.TargetName="Panel1" Storyboard.TargetProperty="Height" To="26" Duration="0:0:0.50" AccelerationRatio="0.6" DecelerationRatio="0.4" />
                                <DoubleAnimation x:Name="Menu_2" Storyboard.TargetName="Panel2" Storyboard.TargetProperty="Height" To="646" Duration="0:0:0.50" AccelerationRatio="0.6" DecelerationRatio="0.4" />
                           </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </StackPanel.Triggers>
            </StackPanel>
        </StackPanel>


However, I'm trying to do the same thing programmatically, so that I can determine at runtime what the new height should be when the user clicks on a panel. I implemented the following EventHandler, but it doesn't work (the Panel heights do not change).
private void Panel1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
      {

         DoubleAnimation oMenuAnimation = new DoubleAnimation();

          oMenuAnimation.From = 26;
          oMenuAnimation.To =646;
          oMenuAnimation.Duration = new Duration(new TimeSpan(0, 0, 0, 500));
          oMenuAnimation.AccelerationRatio = .6;
          oMenuAnimation.DecelerationRatio = .4;
          Storyboard s = new Storyboard();
          Storyboard.SetTargetProperty(oMenuAnimation, new PropertyPath("Height"));
          Storyboard.SetTarget(oMenuAnimation,Panel1);
          Storyboard.SetTargetName(oMenuAnimation, "Panel1");
          s.Children.Add(oMenuAnimation);


          DoubleAnimation oMenuAnimation2 = new DoubleAnimation();


          oMenuAnimation2.To = 26;
          oMenuAnimation2.Duration = new Duration(new TimeSpan(0, 0, 0, 500));
          oMenuAnimation2.AccelerationRatio = .6;
          oMenuAnimation2.DecelerationRatio = .4;

          Storyboard.SetTargetProperty(oMenuAnimation2, new PropertyPath("Height"));
          Storyboard.SetTarget(oMenuAnimation2, Panel2);

          s.Children.Add(oMenuAnimation2);



          s.Begin();

      }


Does anyone know what I may be doing wrong?
QuestionCreate an automatisation for a toolbar and checkboxes on a third party application Pin
Member 1302589023-Jun-17 4:12
Member 1302589023-Jun-17 4:12 
QuestionC# cross compile Pin
Chris-197323-Jun-17 3:47
Chris-197323-Jun-17 3:47 
AnswerRe: C# cross compile Pin
Afzaal Ahmad Zeeshan23-Jun-17 4:28
professionalAfzaal Ahmad Zeeshan23-Jun-17 4:28 
AnswerRe: C# cross compile Pin
Eddy Vluggen23-Jun-17 7:08
professionalEddy Vluggen23-Jun-17 7:08 
QuestionVisual Studio extension - Watch window item selection Pin
Abyss22-Jun-17 9:28
Abyss22-Jun-17 9:28 
QuestionEnd the Scheduled Task if it is running for more than couple of hours C# code Pin
indian14322-Jun-17 8:33
indian14322-Jun-17 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.