We are using context menu with tree node. The tree and context menu are both dynamic and binds on the runtime.
The tree has several levels of nodes and context menu is specific to the nodes at different levels.
The tree supports the multiple selection.
As per our requirement, we need to find multiple selected tree nodes when the user right clicks on any one of the mulitple selected node to open the context menu.
1. Single node selection
When we right click on the single node to open the context menu, the node which was right clicked does not get selected. We have used the following piece of code to identify the node which was right clicked, and it gives us the correct value.
private RadTreeViewItem ClickedTreeViewItem
{
get
{
return radContextMenu.GetClickedElement<RadTreeViewItem>(); }
}
this
.ClickedTreeViewItem.DataContext
2. Multiple nodes selection
In case of multiple selection, we have to select the nodes and we are not able to find the nodes which are selected while using the context menu.
To summarize:
1. We need a way to find the selected nodes in a tree on right click to open the context menu for either single or multiple selection of the tree view item.
2. The node on which the context menu was opened should be selected as well.
| <telerik:GridViewDataColumn Header="X Coordinates" |
| DataMemberBinding="{Binding XCoordinates, Mode=TwoWay}" |
| TextAlignment="Right"> |
| <telerik:GridViewDataColumn.CellTemplate> |
| <DataTemplate> |
| <TextBlock Text="{Binding XCoordinates}" /> |
| </DataTemplate> |
| </telerik:GridViewDataColumn.CellTemplate> |
| <telerik:GridViewDataColumn.CellEditTemplate> |
| <DataTemplate> |
| <telerik:RadNumericUpDown Maximum="10000" Minimum="0" ValueFormat="Numeric" |
| Value="{Binding XCoordinates, Mode=TwoWay}" /> |
| </DataTemplate> |
| </telerik:GridViewDataColumn.CellEditTemplate> |
| </telerik:GridViewDataColumn> |
ObservableCollection<People> peopleByYearData = GetPeopleByYear();
gridViewPeople.ItemsSource = peopleByYearData;
//this displays the data on a simple bar chart.
chartPeopleByYear.ItemsSource = gridViewPeople.ItemsSource;
How do i ensure that the chart updates its view when the gridview is filtered?
i have tried hooking into the Filtered event of the gridview to try and get access to a list of filtered items but I cannot find any such list. The filter displays fine on the gridview but in the Filtered event the gridViewPeople.Items.Count is always == 0.
Thanks
I'm trying to plot a “stepline” chart where AxisX is a DateTime and some points are nulls.
As I didn't find any specific series (I hope you'll address soon), I use LineSeriesDefinizion doubling data point (see code) but:
- null value are treated as 0 (wrong since 0 means 0 value while null means missing value)
- where first value is null, the control throws a NullReferenceException
public MainWindow()
{
InitializeComponent();
ConfigureChart();
}
private void ConfigureChart()
{
LineSeriesDefinition lineSeries = new LineSeriesDefinition();
lineSeries.ShowItemLabels = false;
lineSeries.ShowPointMarks = false;
SeriesMapping actualMapping = new SeriesMapping();
actualMapping.SeriesDefinition = lineSeries;
actualMapping.LegendLabel = "Data";
actualMapping.ItemMappings.Add(new ItemMapping("Day", DataPointMember.XValue));
actualMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue));
radChart.SeriesMappings.Add(actualMapping);
radChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "#VAL{dd-MM-yy}";
radChart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;
radChart.DefaultView.ChartArea.AxisX.IsDateTime = true;
radChart.ItemsSource = MyData.GetData();
}
}
class MyData
{
public DateTime Day { get; set; }
public double? Value { get; set; }
public static List<MyData> GetData()
{
DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
List<MyData> list = new List<MyData>();
list.Add(new MyData() { Day = today, Value = null });
list.Add(new MyData() { Day = today.AddDays(1), Value = 1 });
list.Add(new MyData() { Day = today.AddDays(1), Value = 2 });
list.Add(new MyData() { Day = today.AddDays(2), Value = 2 });
list.Add(new MyData() { Day = today.AddDays(2), Value = 1.5 });
list.Add(new MyData() { Day = today.AddDays(3), Value = 1.5 });
return list;
}
}
Sincerely
Ivano