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
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
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
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?
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
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
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).
My monkey wearing the fedora points and laughs at you.
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..
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.
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
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
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
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.
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)
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
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
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
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
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