Drawing dynamic number of grid lines on wpf canvas - wpf

I have a WPF ink canvas upon which i want to draw grid lines (horizontal and vertical lines representing pixelated canvas). The number of horizontal and vertical lines are going to be dynamic. I have the input i.e. number of those lines in my code behind. How shall i proceed? I hope the question is clear.

Related

How can I add padding to my chart?

As you can see from below my LineSeries chart (Silverlight Toolkit) utilize the whole area. How can I add a padding to it? So that the line does not stop/end/start at the border. For as you can see from the label it gets overlapped with the border, making it look less nice.
Why don't you increase the axis? Like: Vertical axis goes from 1000 to 9000 - and horizontal axis goes from 30.07 up to 08.08.
And: If you want to set margins to the whole control - doesn't margins / padding work for you?

stretchable histogram overlaying a picture

I'm in the process of making a WPF program that:
can scan a bitmap image, pixel-by-pixel, and assign it a data value (0-255)
design a class that allows panning and zooming of the picture
create a histogram, from the data values, that overlays the bitmap image.
I was able to do all three, however the issue that I am having is that the histogram doesn't dynamically (I think that's the word for it) stretch as I re-size the main window. Actually, nothing stretches to the correct size in the main window (the bitmap image just re-centers itself while keeping the same size). The histogram originally started as a transparent canvas that had many rectangle children. I changed it to a grid but am getting the same results as the canvas; the rectangles don't want to stretch horizontally or vertically. If I do set a horz/vert alignment the histogram disappears altogether. Can anyone help with this problem?
I ended up making a class that was a derivative of the canvas class i cave it some rendering overrides and a paint method that took into account the actual width and height of the window.

Panning the display area in WPF

The application will have a menu strip on top and the rest will display lines and shapes. I want to be able to drag and pan the main display area by clicking it and dragging it in any direction.
I am currently drawing items using pixel values (for example a line drawn from (1042,54)to(1240,104). But I think a monitor with a smaller resolution will not be able to display that object. That is why I want to be able to pan the display area.
The lines and shapes are currently being drawn on a gird that I placed inside the window.
If you place the canvas inside a ScrollViewer then if the canvas is larger than the application window it will be displayed with scroll bars.
You can then address points on the canvas with values relative to the canvas rather than the screen.

Filling a Rectangle at different levels with Silverlight Animation?

I am very new to Silverlight. I have a question on Animation. My requirement is, a rectangle should have different levels of fill indication. More clearly say, my rectangle is half filled initially, it has to be either increased/decreased with animation.
Can anyone help me out how can I do this in Silverlight animation?
draw a 2nd rectangle inside the 1st rectangle. adjust the height of the 2nd rectangle to fill up/down.
now mark my reply as the answer.

Silverlight canvas scrollbars

I have read that placing a canvas inside a scrollviewer won't work because the canvas does not report its size. I have been experimenting with different containers (borders, grids, canvases and scrollviewers) and could really do with a simple explanation of how scrollviewers behave within nested containers. e.g. If I have a container hierarchy of UserControl>Grid1>Canvas1>ScrollViewer>Grid2>Canvas2 should scrollbars appear around Grid2 when Canvas2 becomes wider than Canvas1? (or indeed wider than UserControl) If not, how should I organise my containers so I can add loads of uielements to Canvas2 and have scrollbars appear as necessary. (My usercontrol width and height are set to 100%)
Canvas will work with a ScrollViewer if you explicitly give it a size. The problem comes from the fact that if you don't supply a Height and Width for any control it will try and determine it's available area based off it's parent container. A ScrollViewer however has infinite available area.
Take a Grid for example. If I define a Grid that has 2 Star Width columns and 2 Star Height rows. How does the Grid know how wide each of those columns should be? The star says they should be half of the available area, but inside a ScrollViewer the available area is infinity.
What controls are you adding to Canvas2? If you are adding them with fixed positions than the ScrollViewer will expand to house all elements. If you aren't giving them fixed positions than all the controls will stack on top of each other, because that is the arrange behavior of a Canvas

Resources