Page 1 of 2 12 LastLast
Results 1 to 40 of 45

Thread: [RESOLVED] WPF Marquee control

  1. #1

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Resolved [RESOLVED] WPF Marquee control

    In a recent WinForms project, I used a marquee control and I really liked the outcome, so now I'd like to create one for WPF. Unfortunately, the hobby project I'm working on is my first WPF project, so I'm at a loss as to how to proceed...

    Has anyone created such a control for WPF? Or, if not, can anyone point me in the right direction?
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  2. #2
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: WPF Marquee control


  3. #3

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    It seems great, although I do have one question... Is it possible to make the marquee text start entering from the right as soon as it starts disappearing from the left? You know, like those news marquees on TV - they don't have an empty patch when the entire text moves through it once...
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  4. #4
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: WPF Marquee control

    I imagine so but that would mean keeping track of each letter to see if it is visible and if not to place it on the other side of the control!

  5. #5

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    If there is no other way, then so be it... How can I do it?
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  6. #6
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: WPF Marquee control

    There is storyboarding but I have not much on this, Chris128 may be able to help better!

  7. #7

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    Ok then, I hope he'll come by Thanks for your help
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  8. #8

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    I've been working on the code provided in the link, however I've discovered several rather worrying flaws, the most prominent being that when the text exits the bound of the marquee control, it is still drawn! :S This means that this marquee may only be used for cases where the marquee stretched from one end of the form to the other... :S Instead of overlaying other controls over the sides of the marquee (the obvious workaround), is there a more systematical way of solving this issue?
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  9. #9
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    What exactly do you want to 'marquee' ? I mean is this just for a one off or do you want to create this marquee control so that you can then use it in several projects and stick basically any control in it and then make that control appear to marquee across the area of your marquee control? Also will it always be the same size or does it need to be resizable?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  10. #10

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    If possible, I'd like to create a reusable, resizable control which may hold any type of control within and animate it.
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  11. #11
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    I'll see if I can put something together but Im not promising anything
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  12. #12

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    Thanks mate Much appreciated
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  13. #13
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    Hmm tis harder than I thought!
    Have you had a look at this? http://social.msdn.microsoft.com/For...4-4ee3bf55a679
    They are only talking about animating a textblock but I would assume you could get it working for anything, I just havent had chance to try it yet since I found that link
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  14. #14

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    I'm new to WPF so I have only a faint idea as to what a TextBlock is... But I completely agreed with this part of the thread:
    For a true headline scenario, this isn't very useful... at least on CNN the marquees are routinely much longer than the screen width for a single headline.
    since it is exactly the reason I had in mind in the first place (post #3).

    I'll have a look at it, it may be exactly what I need. Thanks a lot for the link!
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  15. #15
    Hyperactive Member Arrow_Raider's Avatar
    Join Date
    Dec 2001
    Location
    AVR Lovers Club
    Posts
    423

    Re: WPF Marquee control

    I have created a marquee that tiles the content so it works at all sizes. You can give it any kind of content you want, but note that the user will not be able to interact with the content (for example, if you make the content a button, the user won't be able to click the button).
    Attached Files Attached Files
    My monkey wearing the fedora points and laughs at you.

  16. #16

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    Why not?
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  17. #17
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    Nicely done Arrow_Raider

    obi1 - I think the reason why you cant interact with the content is because he is using a VisualBrush to basically project the controls onto the surface of the rectangle. So what you are seeing moving is not technically the controls, just their appearance rendered by the visual brush (VisualBrushes are actually very useful in a lot of situations).

    There must be some way to get it working with interactive content though..
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  18. #18

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    But the click should be caught by the rectangle, right? Since chasing the text doesn't seem very attractive...
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  19. #19
    Hyperactive Member Arrow_Raider's Avatar
    Join Date
    Dec 2001
    Location
    AVR Lovers Club
    Posts
    423

    Re: WPF Marquee control

    Yes, you can catch the marquee mousedown event, but just remember that this event is raised when any non-transparent area of the marquee is clicked on.
    My monkey wearing the fedora points and laughs at you.

  20. #20
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    Quote Originally Posted by obi1kenobi View Post
    But the click should be caught by the rectangle, right? Since chasing the text doesn't seem very attractive...
    Ah yes but thats not what we were talking about when we said interactive content. In WPF you can put pretty much any control inside any other control, so we were talking about if you had a few buttons scrolling in this marquee then you wouldnt be able to capture the individual button clicks.
    If you just want to have one click anywhere on the marquee do the same thing then thats not a problem
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  21. #21

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    Oh yeah, it seems so obvious when I read post #15 now... Thanks a lot for all your help guys, I look forward to testing it as soon as I get home
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  22. #22

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    I tried philipsh's solution from the link you provided and it seemed really good. I also tried Arrow_Raider's solution and I really liked the effect. So I wonder if it would be possible to tile several textblock controls next to each other and have them move to the beginning of the line as soon as they are scrolled out of view by the animation...
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  23. #23
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    Huh? Isnt that what already happens?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  24. #24

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    Arrow_Raider's code does that however exactly as you pointed out, clicks are not captured. I meant being able to line up several textblocks in a news ticker-like fashion and then be able to redirect the user to the exact piece of news they clicked - the best of both worlds.
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  25. #25
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    Oh why what does the other one do that I sent you a link to? I thought that did the same thing
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  26. #26

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    You mean in post #2? Well it doesn't repeat the text like Arrow_Raider's control, does it?
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  27. #27
    Hyperactive Member Arrow_Raider's Avatar
    Join Date
    Dec 2001
    Location
    AVR Lovers Club
    Posts
    423

    Re: WPF Marquee control

    You can't display a control multiple times. It only allows one visual to be displayed. To display it more than once, a visual brush must be used. You may be able to create new instances that are copies of the control and load an array of duplicates into an itemscontrol, but this seems hack-like and cludgy to me.
    My monkey wearing the fedora points and laughs at you.

  28. #28
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    Arrow - he is not talking about displaying the same textblock over and over, he means having different textblocks in the same marquee (if thats what you were referring to anyway)
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  29. #29

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    Yes, chris128 is right, that's what I meant. I believe I can put something together from all the code in this thread and the links chris provided. Thank you both for your help.
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  30. #30
    Hyperactive Member Arrow_Raider's Avatar
    Join Date
    Dec 2001
    Location
    AVR Lovers Club
    Posts
    423

    Re: WPF Marquee control

    If you want to have multiple textblocks, you can use an itemscontrol to do that.
    My monkey wearing the fedora points and laughs at you.

  31. #31

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    Ok I finally created a marquee which displays the effect described in post #3 using parts from both Arrow_Raider and the link provided by chris128. I must warn you though, the code is messy since I have limited experience with C# but I didn't want to port everything to VB... I'm open to suggestions as to how to improve the control

    MarqueeControl - Custom.zip
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  32. #32

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    I'm having some issues with the marquee control, as soon as I put it in a project I want to use it in, I get the following runtime error: InvalidOperationException - '_brushTransform' name cannot be found in the name scope of 'System.Windows.Shapes.Rectangle'.

    Any ideas?
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  33. #33
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    What code are you using? The code in that solution you attached in the previous post?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  34. #34

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    Yes, but the part that errors out is copy-pasted from Arrow_Raider's solution.
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  35. #35
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    Well your solution file above works fine for me and I assume it does for you, so how are you 'putting it in another project' exactly?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  36. #36

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    I moved all controls to a WPF control library project, compiled a dll and then referenced it in my current project. That resulted in a cascading failiure and in the end I couldn't even add the control to the form. Then I ported all relevant code from the marquee to VB using Reflector and added the VB code files directly into the project. And now as soon as the storyboard is started, the error message above pops up. I triple-checked the code I ported to VB and as far as I can see it is completely identical to the C# code. I can attach it here if you'd like to take a look at it as well.
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  37. #37
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    I dont know why you wouldnt of been able to just make a DLL and reference it... but yeah can you post your current code here?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  38. #38

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    Here it is

    MarqueeVB.zip
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  39. #39

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: WPF Marquee control

    I just rebuilt the DLL and added it to the project (after making a backup copy) and this time the app starts up just fine but the marquee doesn't scroll, the text just stands still. What gives? When I set the duration property, the storyboard is supposed to start, yet there is no animation... :S
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  40. #40
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WPF Marquee control

    Well I've built it into a DLL and added it to a VB project successfully... but it just doesnt seem to do anything :S
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width