Note that there are some explanatory texts on larger screens.

plurals
  1. POBest method to draw schedule grid on window
    primarykey
    data
    text
    <p>I have a ViewModel entirely setup using observable collections and am able to drill down in my interface to a specified schedule and want to display each day of the week and for each day i want to be able to display 96 different time slots (15 minute increments for 24 hours). Below is the ViewModel code as well as the View code.</p> <p>My question is what is the best way to use a user control. I will want a user control for each day, so I will have 7 controls of the same kind per schedule, but I need someway to get my data-bound data into the user control. Do I need to make custom dependency properties and pass all 96 variables in?</p> <p>If I do so once inside the control do I hard code out a grid with 96 columns and three rows and type each data piece into a corresponding rectangle?</p> <p>My goal is to have a re-sizable schedule control that has the day of the week as text, the hours on the bottom and a color representation of each 15 minute. Each segment can be red, blue, or green, for example. Before with the grid and rectangles it would re-size with the window which was nice. Is there a better way to draw shapes on the screen? Canvas?</p> <p>Thanks, Wesley</p> <pre><code>public class ScheduleVM { public ObservableCollection&lt;Schedule&gt; schedules { get; set; } private static ScheduleVM viewModel = null; public static ScheduleVM getInstance() { if (viewModel == null) viewModel = new ScheduleVM(); return viewModel; } private ScheduleVM() { schedules = new ObservableCollection&lt;Schedule&gt;(); for (byte i = 0; i &lt; 32; i++) schedules.Add(new Schedule()); } } public class Schedule { public ObservableCollection&lt;Day&gt; days { get; set; } public Schedule() { days = new ObservableCollection&lt;Day&gt;(); for (byte i = 0; i &lt; 8; i++) { ObservableCollection&lt;int&gt; values = new ObservableCollection&lt;int&gt;(); for (byte j = 0; j &lt; 96; j++) values.Add(3); days.Add(new Day() { data = values }); } } } public class Day : BaseVM { private ObservableCollection&lt;int&gt; _data; public ObservableCollection&lt;int&gt; data { get { return _data; } set { _data = value; OnPropertyChanged("data"); } } } </code></pre> <p>Below is my current XAML </p> <pre><code>&lt;ItemsControl Name="schedule"&gt; &lt;ItemsControl.Resources&gt; &lt;converters:OnOffColorConverter x:Key="colorConverter"/&gt; &lt;/ItemsControl.Resources&gt; &lt;ItemsControl.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;controls:Day data="{Binding}" /&gt; &lt;/DataTemplate&gt; &lt;/ItemsControl.ItemTemplate&gt; &lt;/ItemsControl&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload