title: How to render dynamic data in a custom WPF control, such as a line graph?
body: <p>I'm working on a <code>LineGraph</code> control which consists many <code>DependencyProperties</code> that affect how the control should display its data.  For example, the control contains the following properties to affect its axes:</p>
  <ul>
  <li><code>AxisStroke</code> - Color of the axes.</li>
  <li><code>AxisThickness</code> - Stroke thickness of the axes.</li>
  </ul>
  <p>It also contains properties for display numbers &amp; tick marks</p>
  <ul>
  <li><code>VerticalTicks</code> - True/False to indicate whether or not ticks appear along the vertical axis</li>
  <li><code>HorizontalTicks</code> - True/False to indicate whether or not ticks appear along the horizontal axis</li>
  <li><code>VerticalMin</code> - Minimum value on the vertical axis (numeric)</li>
  <li><code>VerticalStep</code> - The distance in between each vertical tick</li>
  <li><code>VerticalMax</code> - Maximum value on the vertical axis (numeric)</li>
  <li><code>HorizontalMin</code> - Minimum value on the horizontal axis (numeric)</li>
  <li><code>HorizontalStep</code> - The distance in between each horizontal tick</li>
  <li><code>HorizontalMax</code> - Maximum value on the horizontal axis (numeric)</li>
  </ul>
  <p>And many more properties exist to allow for different line styles on a single graph (<code>LineColor</code>, <code>LineThickness</code>, <code>DataPointShape</code>, and <code>DataPointIcon</code> to name a few).</p>
  <p>My goal is to be able to call out my <code>LineGraph</code> in XAML to insert it into a <code>Window</code>.  I would like to be able to specify each of these settings inside the XAML as well, and see the new rendered image of the control in the <strong>WPF designer</strong>.</p>
  <p>Now, given there is a lot of geometric shapes to render on the <code>LineGraph</code>, I though using a <code>Canvas</code> would be a good choice to render the data.  Unfortunately, when I'm working in XAML, I cannot perform computations for the locations of shapes based on the control's width &amp; height.</p>
  <p>And yes, the shapes' locations must be computed because the data points for the graph are dynamic and the tick-related information is dynamic.  Not to mention, I would like to display the actual values along each axis of the <code>LineGraph</code>.</p>
  <p>So, I thought I might be able to display this control as if I was doing the rendering in C# code.  <em>Other windowing frameworks sometimes provide a <code>Render</code> method that can be used for laying out all of the sub-components.</em></p>
  <p>Doing this, however, doesn't seem possible since WPF relies heavily on XAML for the visual appearance of controls.  Also, requiring that the WPF designer must display the <code>LineGraph</code> based on the properties and data specified, it doesn't seem like C# code would solve the problem.</p>
  <p>I suppose my questions are these:</p>
  <h2>How can I render data dynamically inside of a WPF control?</h2>
  <h2>Am I able to specify in C# how my control is rendered, allowing the WPF designer to reflect it?</h2>
  <hr>
  <p><strong>Side Note:</strong><br>
  I've done quite a bit of research, but I am only finding information on how to implement more simple types of controls.  If you know of any references that contain information on this topic, please feel free to post them in addition to your answers.  I will be more than happy to learn how to do this completely.</p>
  <p><strong>EDIT:</strong>
  I've created a graph using Excel to elaborate what the <code>LineGraph</code> control might look like if it has correct data and properties.</p>
  <p><img src="https://i.stack.imgur.com/12Tm7.png" alt="Line Graph" /></p>