WPF/C#: Images rotating from a listview? - wpf

I just want ask for your comments/suggestions on how to create a customized listview (if that's a good implementation) in WPF that displays images coming from a table from a database (more like a playlist) that rotates similar to a film (moving horizontally - on loop)
Any ideas?

If you have a list of Images, you can create an Image control for each one, put each Image control in a horizontal StackPanel, put the StackPanel inside a Canvas (of whatever size of the "film"), and animate the Left property of the Canvas to have the images roll.
Of course, if you need that the images wrap (the first one after the last one), you could forget about the StackPanel and move each Image separately.

Related

Container with shape like circle lines border and textblock

I am creating grid dynamically and adding 200 rows and 240 columns and adding stackpanel at each position of the grid So totally i am drawing 4800 stackpanels .Now i want to add lines circle and 3 text blocks in each of the stackpanel
Till I am adding grid add stackpanel it working fine and rendering all controls within 4 seconds which is okay .But as i started adding text block as a child control in scakpanel it taking too much time . Should I use any other better and light weight control . Or instead of adding text block can use DrawText on show text in stack panel. I further want to use drag drop functionality for stack panel so i must use only container will move along with its child elements
I think you can avoid adding the columns and the rows phase, instead of using a Grid you can simply use a canvas and handle the tabular view (rows and columns) from your code behind using the the Left and Top properties.
Beside, a canvas will be convenient to use the drag and drop functionnality. you can use for that the MouseDragElementBehavior. but then you have to deal with absolute positioning according to your Parent Window rather then the Top and Left Properites. It still realtively easy to do.
If you're using a large view where there is only a part of it displayed, you can load only the part in view.
I Hope this will be helpfull.

Aligning components with each other in WPF

A WPF application consists of a uniform grid of arbitrary size. Each cell in the grid contains a canvas. Each canvas is a target for a drag and drop operation.
When I drag another canvas and drop it onto a canvas inside the grid I want the top left corners of the dragged canvas(source) and the target canvas to align, essentially placing the source on top of the target. The behaviour I'm looking for is a snap-to-grid effect.
Currently when I use element.GetValue(Canvas.LeftProperty) the result in NaN. The problem is to determine the position of the corner for a canvas inside the grid, but relative to the entire window. I would prefer to use the grid, as it automatically resize as the window resize.
Is it possible to get the actual position of a canvas inside a grid even when the grid size changed or alternatively specify a canvas to be aligned to another canvas inside the grid?
This problem was solved by drawing each canvas onto another canvas by specifying the top and left properties of the canvas, I had to scratch the grid. I specified the position of every canvas by using
Canvas.SetLeft(Me, position.X)
Canvas.SetTop(Me, position.Y)
where Me is an instance of the canvas.
It is now easy to get the top and left properties of every canvas. The only problem now is I have to implement the resizing of every canvas manually.

WPF - copying items with brushes attached

I'm developing a multi track video player in wpf and need to be able to copy the video that is playing in one grid layout of the main window into a seperate window that will go out of a projector. The videos are loaded and drawn onto rectangles using drawing brush and are added to a grid. I can't call clone on the rectangle, or the grid, or the canvas, so I'm currently resorting to copying the drawing brushes, passing them through to the otherwindow class and reassigning them to newly drawn rectangles.
However, this gets even worse as I'm 'cross-fading' between two video by drawing another rectangle with a new video in front, then changing the opacity value of the front video to gradually block out the one behind. So I now have two brushes on two rectangles tied to storyboards to animate, and I'm having to pass everything through and basically compute everything twice.
Is there any sensible way of doing this? I'd love to be able to literally grab the pixels from one area of the main video and display them in the second window, but everything seems abstracted away.
Any suggestions would be a massive help
Have you looked at VisualBrush?

How can I animate a transition when moving a child from one panel to another in Silverlight

I would like to animate a transition when moving content between two panels. I am getting a bit map image of a detail record and docking it as a thumbnail in the panel below. The docking area is in a footer grid and the content detail is in another grid that sits above the dock area (the dock and the main content area live in separate rows of the root layout control - another grid).
I have tried implementing this with a ScaleTransform and a TranslateTransform, simultaneously shrinking the image and moving it towards the footer control. When it moves into the footer control, it gets clipped even though the image Canvas.ZIndex property is set to a very high number. Eventually the thumnbail will need to be a child of a StackPanel that sits inside the footer grid.
Thanks for your consideration and help.
I had a similar problem (clipping) with a WPF animation I had. The problem was that the owner of the animation needed to be a parent of both containers for the animation to work (in my case I made it the actual window holding the containers).
Without any code, I can't see if that is your problem, but I thought I would throw it out there.
You can see my code where I animate moving from one container to another here:
http://wiassistant.codeplex.com/sourcecontrol/changeset/view/36638?projectName=WIAssistant#924851
(See the AnimatePaneBox method at the bottom of the file.) This may or may not be useful to you.
I've done something similar by creating a Canvas that sits over the top of both containers, using a WritableBitmap (if necessary) to create a rendering of the object that you're moving and attach it to that Canvas, animate the bitmap (translate, scale, opacity, whatever), and then pop the new object in under it at the end of the animation. It can be brittle if your controls need to be able to move or resize, but in most of my circumstances it's been a reliable hack.

Silverlight magnify contents of one canvas and show zoom contents in another canvas

I have a Silverlight app with a canvas with some ellipes in it. I have another canvas below it with no elements.
What I want to do is, when I click in the first cancas, I want to copy the contents of the first canvas and zoom in where I clicked my mouse and show it in the second canvas.
I want functionality like Local Connection gives you in silverlight 3 but as the canvases are in the same xaml and app it would be overkill to use Local Connection.
My solution is really simple I'm almost embarrassed.
I have set the properties of my second canvas to match my first canvas and duplicated any static elements that wont change (I plan to try pull these from one xaml file)
When I click the first canvas I add a new ellipse at the point where I clicked. In the same function I create another ellipse element and add it to my second canvas.
cnvSource.Children.Add(ellipseElement);
cnvTarget.Children.Add(ellipseElementCopy);
I can then create a zoom function on my second canvas so that the first canvas is unafected.

Resources