locked
Images using scrollviewers

    Question

  • How can i display the multiple images in the scrollviewer in visual studio Ultimate 2013?
    Wednesday, August 20, 2014 11:12 AM

Answers

  • First and foremost, you don't need to use a pirated version of VS2013.  For your purposes, VS Express works plenty well and is completely free provided by MS.

    You can put images in a scrollviewer by putting them in a stackpanel.  So, your code would look something like this.

    <ScrollViewer>
       <StackPanel>
    
           <Image x:Name="image1"/>
           <Image x:Name="image2"/>
           etc......
    
       </StackPanel>
    </ScrollViewer>

    Wednesday, August 20, 2014 3:21 PM
  • Here is how I would do it.  Note that this can also be achieved with animation.  In this particular case, I would take the char at the beginning of the text string and move it to the back.  To control the speed, you can add a timer.

    In your xaml, you would have a textblock.

    <TextBlock x:Name="yourtextblock" Text = "Your texts here..."/>

    In the corresponding c# code...

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
         CompositionTarget.Rendering += MovingTexts;
    }
    
    void MovingTexts(object sender, object e)
    {
         yourtextblock.Text = yourtextblock.Text.Substring(1)  + yourtextblock.Text.Substring(0,1);
    }

    Thursday, August 21, 2014 12:57 PM

All replies

  • First and foremost, you don't need to use a pirated version of VS2013.  For your purposes, VS Express works plenty well and is completely free provided by MS.

    You can put images in a scrollviewer by putting them in a stackpanel.  So, your code would look something like this.

    <ScrollViewer>
       <StackPanel>
    
           <Image x:Name="image1"/>
           <Image x:Name="image2"/>
           etc......
    
       </StackPanel>
    </ScrollViewer>

    Wednesday, August 20, 2014 3:21 PM
  • Thank you, It works fine but can i place the text under each image?
    Thursday, August 21, 2014 12:17 PM
  • Thank you, It works fine but can i place the text under each image?

    You could just add a TextBlock below an Image element:

            <ScrollViewer>
                <StackPanel>
    
                    <Image x:Name="image1"/>
                    <TextBlock>text...</TextBlock>
                    <Image x:Name="image2"/>
                    <TextBlock>text...</TextBlock>
    
                </StackPanel>
            </ScrollViewer>


    Thursday, August 21, 2014 12:19 PM
  • Ok Thankyou, How can i add a text moving from left to right like a marquee in HTML?
    Thursday, August 21, 2014 12:41 PM
  • Here is how I would do it.  Note that this can also be achieved with animation.  In this particular case, I would take the char at the beginning of the text string and move it to the back.  To control the speed, you can add a timer.

    In your xaml, you would have a textblock.

    <TextBlock x:Name="yourtextblock" Text = "Your texts here..."/>

    In the corresponding c# code...

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
         CompositionTarget.Rendering += MovingTexts;
    }
    
    void MovingTexts(object sender, object e)
    {
         yourtextblock.Text = yourtextblock.Text.Substring(1)  + yourtextblock.Text.Substring(0,1);
    }

    Thursday, August 21, 2014 12:57 PM
  • Thank you, How can we add the timer for the text for your given answer?
    Friday, August 22, 2014 4:08 AM