or
public partial class ManufacturersAndPartsSearch : Window { private ViewModels.ManufacturersAndPartsSearchViewModel vm; public ManufacturersAndPartsSearch() { InitializeComponent(); var context = new ViewModels.ManufacturersAndPartsSearchViewModel(this); this.vm = context; this.DataContext = vm; GridViewTableDefinition d = new GridViewTableDefinition(); d.Relation = new Telerik.Windows.Data.PropertyRelation("ChildParts"); //add child table defination to gridview this.GridView.ChildTableDefinitions.Add(d); this.GridView.DataLoaded += GridView_DataLoaded; //this is to alter changes to each child grid this.GridView.DataLoading += GridView_DataLoading; //event to check and set the view model's current row to a heirarchial's currently selected row if selected //explanation /*The original code used data binding to set the current row in the viewmodel equal to the current row in the grid this worked for the original purpose; however, since heirarchial grids are created for each row in the parent grid that has parts saved in the database then there is no way to bind their currently selected row properties to the viewmodel The databinding was ditched and instead this route was taken which accounts for both types of grids*/ this.GridView.SelectionChanged += GridView_SelectionChanged; } void GridView_SelectionChanged(object sender, SelectionChangeEventArgs e) { var grid = sender as RadGridView; var item = grid.SelectedItem; this.vm.CurrentItem = item; MessageBox.Show(item.GetType().ToString()); }public class PartsManufacturerViewModel : Accu_Base_Lib.Bases.ModelViewModelBase<DAL.PartsManufacturer> { public string Id { get { return (string)GetValue(IdProperty); } set { SetValue(IdProperty, value); } } // Using a DependencyProperty as the backing store for Id. This enables animation, styling, binding, etc... public static readonly DependencyProperty IdProperty = DependencyProperty.Register("Id", typeof(string), typeof(PartsManufacturerViewModel)); public string Name { get { return (string)GetValue(NameProperty); } set { Debug.WriteLine("ViewModel Name Changed " + this.Name); SetValue(NameProperty, value); } } // Using a DependencyProperty as the backing store for Name. This enables animation, styling, binding, etc... public static readonly DependencyProperty NameProperty = DependencyProperty.Register("Name", typeof(string), typeof(PartsManufacturerViewModel)); private ObservableCollection<PartViewModel> _childParts; public ObservableCollection<PartViewModel> ChildParts { get { if (this._childParts == null) { GetChildren(); } return this._childParts; } set { this._childParts = value; } } public PartsManufacturerViewModel(DAL.PartsManufacturer model) { base.Init(model); //Fills this viewmodel based off the model supplied. UpdateViewModelFromModel(); } public PartsManufacturerViewModel() { base.Init(); this.Model.Id = Guid.NewGuid().ToString(); this.Model.Name = string.Empty; UpdateViewModelFromModel(); }public class PartViewModel : Accu_Base_Lib.Bases.ModelViewModelBase<DAL.Part> { public string Id { get { return (string)GetValue(IdProperty); } set { SetValue(IdProperty, value); } } // Using a DependencyProperty as the backing store for Id. This enables animation, styling, binding, etc... public static readonly DependencyProperty IdProperty = DependencyProperty.Register("Id", typeof(string), typeof(PartViewModel)); public string ManufacturerId { get { return (string)GetValue(ManufacturerIdProperty); } set { SetValue(ManufacturerIdProperty, value); } } // Using a DependencyProperty as the backing store for ManufacturerId. This enables animation, styling, binding, etc... public static readonly DependencyProperty ManufacturerIdProperty = DependencyProperty.Register("ManufacturerId", typeof(string), typeof(PartViewModel)); public string Name { get { return (string)GetValue(NameProperty); } set { SetValue(NameProperty, value); } } // Using a DependencyProperty as the backing store for Name. This enables animation, styling, binding, etc... public static readonly DependencyProperty NameProperty = DependencyProperty.Register("Name", typeof(string), typeof(PartViewModel)); public string ModelNo { get { return (string)GetValue(ModelNoProperty); } set { SetValue(ModelNoProperty, value); } } // Using a DependencyProperty as the backing store for ModelNo. This enables animation, styling, binding, etc... public static readonly DependencyProperty ModelNoProperty = DependencyProperty.Register("ModelNo", typeof(string), typeof(PartViewModel)); public decimal Price { get { return (decimal)GetValue(PriceProperty); } set { SetValue(PriceProperty, value); } } // Using a DependencyProperty as the backing store for Price. This enables animation, styling, binding, etc... public static readonly DependencyProperty PriceProperty = DependencyProperty.Register("Price", typeof(decimal), typeof(PartViewModel)); public PartViewModel(DAL.Part model) { base.Init(model); //Fills this viewmodel based off the model supplied. UpdateViewModelFromModel(); } public PartViewModel() { base.Init(); this.Model.Id = Guid.NewGuid().ToString(); UpdateViewModelFromModel(); }<Window x:Class="BarDensity.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:local="clr-namespace:BarDensity" Title="MainWindow" Height="750" Width="1000"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <telerik:RadCartesianChart Margin="5" x:Name="PropertyChart"> <telerik:RadCartesianChart.Behaviors> <telerik:ChartPanAndZoomBehavior ZoomMode="Both" PanMode="Both" /> </telerik:RadCartesianChart.Behaviors> <telerik:RadCartesianChart.Grid> <telerik:CartesianChartGrid MajorLinesVisibility="XY" /> </telerik:RadCartesianChart.Grid> <telerik:RadCartesianChart.HorizontalAxis> <telerik:DateTimeContinuousAxis LabelFitMode="Rotate" LabelFormat="yyyy-MMM" GapLength="0.5"/> </telerik:RadCartesianChart.HorizontalAxis> <telerik:RadCartesianChart.VerticalAxis> <telerik:LinearAxis /> </telerik:RadCartesianChart.VerticalAxis> <telerik:RadCartesianChart.Series> <telerik:BarSeries CategoryBinding="Date" ValueBinding="Value" ItemsSource="{Binding Path=Series1}"> <telerik:BarSeries.PointTemplate> <DataTemplate> <Rectangle Fill="Blue" /> </DataTemplate> </telerik:BarSeries.PointTemplate> </telerik:BarSeries> <telerik:LineSeries CategoryBinding="Date" ValueBinding="Value" ItemsSource="{Binding Path=Series1}" Stroke="Red"> </telerik:LineSeries> </telerik:RadCartesianChart.Series> </telerik:RadCartesianChart> <StackPanel Grid.Row="1" Orientation="Horizontal"> <Label>MaximumTicks:</Label> <telerik:RadNumericUpDown IsEditable="True" Minimum="10" Maximum="50" Value="{Binding Path=MaximumTicks}"/> </StackPanel> </Grid></Window>namespace BarDensity{ public class MyPoint { public DateTime Date { get; set; } public Double Value { get; set; } } public partial class MainWindow : Window { private int _MaximumTicks = 20; public List<MyPoint> Series1 { get; private set; } public int MaximumTicks { get { return _MaximumTicks; } set { if (_MaximumTicks != value) { _MaximumTicks = value; DateTimeContinuousAxis dateAxis = PropertyChart.HorizontalAxis as DateTimeContinuousAxis; if (dateAxis != null) dateAxis.MaximumTicks = _MaximumTicks; } } } public MainWindow() { Series1 = new List<MyPoint>(); DateTime startDate = new DateTime(2014, 1, 1); for (int i = 0; i < 1000; i++) Series1.Add(new MyPoint() { Date = startDate.AddMonths(i), Value = (Math.Sin(i / 100.0)) * 500 }); InitializeComponent(); DataContext = this; } }}