0

I'm working on my own plotting library, but i've run into a problem. I have the following code to put my polyline on the windowsphone page:

System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
{
    graph.AddSinglePoint(x);
    graph.Update();
    LayoutRoot.UpdateLayout();
}); 

LayoutRoot.Children.Add(graph.line);

(its in a begin invoke, because i do this inside a timer_tick void which is called by a timer timeout(ms)

Only problem with this is, when i want to have my graph postioned lower on the form (in example y= 300 + the actual Y value). It pushes everything on my form down by 300. What I had in mind was the following:

Layout: Page Title

Some filling (listboxes, checkboxes, etc)

At the bottom: My graph (polyline)

How do I acomplish something like that?

Bart Teunissen
  • 1,420
  • 5
  • 20
  • 43

2 Answers2

2

You need to learn about the Silverlight Layout System, the location of each element on screen is determined by the panel which it is located within. Some panels, such as StackPanel, 'stack' each of their children, so that no two items can overlap. Whereas others like Grid and Canvas permit an overlap.

ColinE
  • 68,894
  • 15
  • 164
  • 232
2

If you use a Grid for LayoutRoot you have to set the row and column of your graph:

   Grid.SetRow(graph,2);
   Grid.SetColumn(graph,...);

I personally would do it differently and use a separate control for my graph, eg a Canvas, so the layout looks like this:

Layout: Page Title
Some filling (listboxes, checkboxes, etc)
At the bottom: Canvas

then add the graph to the Canvas instead of the LayoutRoot. You can position controls in a Canvas by absolute coordinates via the dependency properties Top and Left.

thumbmunkeys
  • 20,606
  • 8
  • 62
  • 110