Hi,
please can you advice me how to achieve range selection in RadCartesianChart which has dynamic number of series?
For chart itself I used ChartSeriesProvider as descripted in your tutorial but now I stuck with range selection.
Many thanks!
I have a RadCartesianChart that I am dynamically adding linear series to. I set the minimum and maximum for the y-axis but sometimes it doesn't show a tick for the maximum value at the top of the y-axis. How can I get the graph to always display a tick for the maximum value?
Thanks
<
br
> RecurrenceTask[] RecurrenceTask_Array = new RecurrenceTask[3];
for (int i = 0; i < RecurrenceTask_Array.Length; i++)
{
RecurrenceTask_Array[i] = new RecurrenceTask(today.AddYears(11), today.AddHours(1), "Recurrence Series" + i.ToString())
{
Recurrences = { recurrenceTask1, recurrenceTask2, recurrenceTask3 }
};
}
for (int i = 0; i < RecurrenceTask_Array.Length; i++)
{
gts[0].Children.Add(RecurrenceTask_Array[i]);
gts[1].Children.Add(RecurrenceTask_Array[i]);
}
for (int i = 0; i < gts.Length; i++)
{
this.Tasks.Add(gts[i]);
}
this source occur argumentException
can i use RecurrenceTask in array?
Hello,
I've based my code on the RecurringTask example project.
I was able to get my desired visual result but I've now discovered an action that causes my application to crash.
This makes it pretty much unusable, so I need to find a solution or at least a way to catch the exception and prevent it from crashing.
I've been able to pinpoint the cause of my problem, but have been unable to solve this by myself.
Let me start by describing my current situation/environment.
In the RecurringTask_WPF example project if you collapse the "Recurrence Series" (the parent tree node) then you can see all the child recurring tasks next to each other.
When you click on one of the events, so for example: "Recurrence 1" block (in the TimeRuler Part of the RadGanttView), then this specific recurring task gets selected. This causes the tree node to be expanded automatically and the selected task/event becomes highlighted.
This behaviour works perfectly as intended and I wish to keep it like that exactly.
However once you nest recurring tasks into one extra level of hierarchy, which is on my requirements, an exception is thrown and the program stops working.
First I'll give you the code that changes the example project in order to recreate the problem. (This should also help with explaining the exact problem)
You should replace the GetTasks() method of the ViewModel.cs with the code below:
private
ObservableCollection<IGanttTask> GetTasks()
{
var collection =
new
ObservableCollection<IGanttTask>();
var today = DateTime.Today.AddHours(8);
var child1 =
new
RecurrenceTask(today, today.AddHours(4),
"Reccurence 1"
);
var child2 =
new
RecurrenceTask(today.AddHours(0), today.AddHours(12),
"Reccurence 2"
);
var child3 =
new
RecurrenceTask(today.AddHours(13), today.AddHours(20),
"Reccurence 3"
);
var task2 =
new
RecurrenceTask(today.AddHours(13), today.AddHours(20),
"Recurrence Series2"
)
{
Children = { child3 }
};
var task1 =
new
RecurrenceTask(today, today.AddHours(20),
"Recurrence Series1"
)
{
Children = { child1, child2, task2 }
};
collection.Add(task1);
var taskWithoutRecurrence =
new
GanttTask(today.AddHours(8), today.AddHours(13),
"Task Without Recurrence"
);
taskWithoutRecurrence.Children.Add(
new
GanttTask(today.AddHours(9), today.AddHours(12),
"Child Task"
));
collection.Add(taskWithoutRecurrence);
return
collection;
}
When you run the example with these code changes, you should see that the "Recurrence 3" task now is moved into a new "Recurrence Series2".
This new series is also a child of the original "Recurrence Series1".
So when then all the nodes become collapsed you can still see all child recurrences next to each other.
If you now click on the "Recurrence 3" event (in the TimeRuler Part of the RadGanttView) the application will throw a System.NullReferenceException.
This is the StackTrace (it is in Dutch, but I believe it should still be readable):
bij System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
bij System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
bij Telerik.Windows.Rendering.VirtualizedGridPanel.Handler.SetArrangeRect(Int32 column, Int32 row, Rect rect)
bij Telerik.Windows.Rendering.Internal.GridRenderingHelper.MeasureItemsCore(Rect viewport, IGridContainersHandler handler)
bij Telerik.Windows.Rendering.Internal.GridRenderingHelper.MeasureItems(Rect viewport, IGridContainersHandler handler)
bij Telerik.Windows.Rendering.VirtualizedGridPanel.MeasureContainers(IContainerRecycler recycler, Size availableSize)
bij Telerik.Windows.Rendering.Virtualization.VirtualizedPanel.MeasureOverrideCore(Size availableSize)
bij Telerik.Windows.Rendering.ScrollablePanel.MeasureOverride(Size availableSize)
bij System.Windows.FrameworkElement.MeasureCore(Size availableSize)
bij System.Windows.UIElement.Measure(Size availableSize)
bij Telerik.Windows.Controls.GanttPresenterPanel.MeasureContainer(UIElement container, Size measureSize)
bij Telerik.Windows.Controls.GanttPresenterPanel.MeasureOverride(Size availableSize)
bij System.Windows.FrameworkElement.MeasureCore(Size availableSize)
Here are some other observations that might help you find the exact cause of this problem:
It would seem that the problem only occurs when nested nodes are collapsed and a child task of a hierarchy that is at least 2 levels deep gets selected.
Now I would just like to find a way to stop my program from crashing.
I've tried handling click events in order to prevent the user from clicking on events in the TimeRuler Part of the RadGanttView, but I wasn't able to figure out how to and I would also still like to keep the behaviour of the automatic expanding and selecting the specific task.
I've also tried to implement a click-command which showed me that the expanding actually works correctly and the exception only occurs afterwards.
Any help would be very much appreciated.
Hello,
I trying to move rows up or down depending on user selection from the Context Menu.
And for some reason (still trying to figure out), the IndexOf is returning -1.
Below are my XAML code =>
<telerik:RadGridView x:Name="gridView1" Grid.Row ="1" AutoGenerateColumns="False" Margin="0,5,0,10" FontSize="12" Deleted="OnDeletedIO"
Deleting="OnDeletingIO" telerik:StyleManager.Theme="Summer" DataGridCell.GotFocus="DataGrid_CellGotFocus">
<telerik:RadGridView.ContextMenu>
<ContextMenu >
<MenuItem Header="MoveUp" Click="MoveUp_click"/>
</ContextMenu>
</telerik:RadGridView.ContextMenu>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding name}" Header="Name" IsReadOnly="False"/>
<telerik:GridViewComboBoxColumn x:Name="ComboGroup" DataMemberBinding="{Binding group}" Header="Group"/>
<telerik:GridViewComboBoxColumn x:Name="ComboRTU" DataMemberBinding="{Binding rtu}" Header="RTUs"/>
<telerik:GridViewComboBoxColumn x:Name="ComboOP" DataMemberBinding="{Binding op}" Header="Operation"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding addr}" Header="Address"/>
<telerik:GridViewComboBoxColumn x:Name="ComboTypes2" DataMemberBinding="{Binding dataType}" Header="Data Type"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding swapByte}" Header="Byte
Swapping"
IsReadOnly="True">
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
C# code =>
namespace MBM_WPF
{
public partial class MainWindow : Window
{
MBM mbm1 ;
MBM_view mbmView;
public MainWindow(string path)
{
StyleManager.ApplicationTheme = new SummerTheme();
InitializeComponent();
logger = LogManager.GetLogger("Instruct.MBM_Main");
Configpath = path;
//Populating ItemsSource here
catch
{
mbm1 = new MBM();
mbmView = new MBM_view(mbm1, OnSettingChanged);
BindMyData();
}
}
private void MoveUp_click(object sender, RoutedEventArgs e)
{
//Get the clicked MenuItem
var menuItem = (MenuItem)sender;
//Get the ContextMenu to which the menuItem belongs
var contextMenu = (ContextMenu)menuItem.Parent;
//Find the placementTarget
var item = (RadGridView)contextMenu.PlacementTarget;
int index = this.gridView1.Items.IndexOf(item.SelectedItem);
this.gridView1.Items.Remove(item.SelectedItem);
this.gridView1.Items.Insert(index - 1, item.SelectedItem);
item.SelectedItem = item;
mbmView.IoListCleanUp();
mbmView.AlarmsCleanUp();
}
}
}
Please help.
Thank you!!
Regards,
Darren
I am attempting to set default values to a Telerik RadDataForm in the InitializingNewItem Event. RadDataForm is linked to a RadGridView as the Source, the intention is that when an item is selected in the grid and this is present in the dataform, clicking the Add New Item will pre-populate the dataform with some key data from the previously selected item.
You (Telerik) state: "Occurs when a new item is being added but after the AddingNewItem event. You can use this to set initial values for the initialized objects by passing an instance to the InitializingNewItemEventArgs' DataItem property."
However simply using:
private void RadDataForm_InitializingNewItem(object sender, Telerik.Windows.Controls.Data.DataForm.InitializingNewItemEventArgs e)
{
RadDataForm d = sender as RadDataForm;
// Copy and set all data to existing record
e.DataItem = d.CurrentItem as GetParts_Result;
// Change some data to another default value
(GetParts_Result)e.DataItem).Name = "New Name";
}
This causes a ArgumentNullException error for 'Parameter name: Key'?
Is there a working example of this event being utilised available...
Hi
Is there a way to Preview the SelectionChanged, and also stop the Navigation.
Something like " PreviewSelectionChanged" on RadTabControl, where I can set "Handled=true" to stop navigation.
/Peter
I have a ViewModel object with multiple properties I want to plot (such as Value1 and Value2 in DualSample below). I currently have this working with a SeriesProvider that includes a different SeriesDescriptor and ValueBinding for each property, but using the same ItemsSourcePath.
However, I now have some data sets to plot that have a different sample arrangement (such as only having Value1 in SingleSample, and missing Value2). If I try to use the existing SeriesProvider definition, I get an exception because the SensorValue2Binding doesn't work since the sample is a different type. I was going to change this to use a SeriesDescriptorSelector, but I don't see how to get multiple series from a single ViewModel object as before. The only solution I see is to create separate lists for each property I want to plot, but I'd rather avoid that is I can, mostly to help save on memory usage.
ViewModel definition:
public
interface
ISample
{
}
// Would like to plot this on the same chart as DualSample
public
class
SingleSample : ISample
{
public
Double Value1;
public
DateTime Timestamp;
}
// This is currently working
public
class
DualSample : ISample
{
public
Double Value1;
public
Double Value2;
public
DateTime Timestamp;
}
public
class
Sensor
{
// A Sensor might have a set of DualSample values, or a set of SingleSample values, but not both.
public
ObservableCollection<ISample> SensorData;
}
Currently working solution for DualSample only:
<!-- Existing solution that working with DualSample only -->
<
telerik:RadCartesianChart.SeriesProvider
>
<
telerik:ChartSeriesProvider
Source
=
"{Binding SensorList}"
>
<!-- When SensorData includes DualSample values, both series descriptors below are used,
so I get series for both Value1 and Value2 -->
<
telerik:ChartSeriesProvider.SeriesDescriptors
>
<
telerik:CategoricalSeriesDescriptor
ItemsSourcePath
=
"SensorData"
>
<
telerik:CategoricalSeriesDescriptor.Style
>
<
Style
TargetType
=
"telerik:LineSeries"
BasedOn
=
"{StaticResource {x:Type telerik:LineSeries}}"
>
<
Setter
Property
=
"ValueBinding"
Value
=
"{StaticResource SensorValue1Binding}"
/>
<
Setter
Property
=
"VerticalAxis"
Value
=
"{StaticResource Value1Axis}"
/>
</
Style
>
</
telerik:CategoricalSeriesDescriptor.Style
>
</
telerik:CategoricalSeriesDescriptor
>
<!-- If I have a SensorData collection of SingleSamples, the SensorValue2Binding values
and the plot crashes with the following ArgumentException:
"The value Telerik.Windows.Controls.ChartView.LineSeries is not of type
Telerik.Windows.Controls.ChartView.CartesianSeries and cannot be used in this generic collection"
<
telerik:CategoricalSeriesDescriptor
ItemsSourcePath
=
"SensorData"
>
<
telerik:CategoricalSeriesDescriptor.Style
>
<
Style
TargetType
=
"telerik:LineSeries"
BasedOn
=
"{StaticResource {x:Type telerik:LineSeries}}"
>
<
Setter
Property
=
"ValueBinding"
Value
=
"{StaticResource SensorValue2Binding}"
/>
<
Setter
Property
=
"VerticalAxis"
Value
=
"{StaticResource Value2Axis}"
/>
</
Style
>
</
telerik:CategoricalSeriesDescriptor.Style
>
</
telerik:CategoricalSeriesDescriptor
>
</
telerik:ChartSeriesProvider.SeriesDescriptors
>
</
telerik:ChartSeriesProvider
>
</
telerik:RadCartesianChart.SeriesProvider
>
Attempted solution to work with both DualSample and SingleSample:
<!-- Attempted solution that I would like to work with both DualSample and SingleSample data sets -->
<
telerik:RadCartesianChart.SeriesProvider
>
<
telerik:ChartSeriesProvider
Source
=
"{Binding SensorList}"
>
<
telerik:ChartSeriesProvider.SeriesDescriptorSelector
>
<
local:MySeriesDescriptorSelector
>
<
local:MySeriesDescriptorSelector.Value1SeriesDescriptor
>
<
telerik:CategoricalSeriesDescriptor
ItemsSourcePath
=
"SensorData"
>
<
telerik:CategoricalSeriesDescriptor.Style
>
<
Style
TargetType
=
"telerik:LineSeries"
BasedOn
=
"{StaticResource {x:Type telerik:LineSeries}}"
>
<
Setter
Property
=
"ValueBinding"
Value
=
"{StaticResource SensorValue1Binding}"
/>
<
Setter
Property
=
"VerticalAxis"
Value
=
"{StaticResource Value1Axis}"
/>
</
Style
>
</
telerik:CategoricalSeriesDescriptor.Style
>
</
telerik:CategoricalSeriesDescriptor
>
</
local:MySeriesDescriptorSelector.Value1SeriesDescriptor
>
<
local:MySeriesDescriptorSelector.Value2SeriesDescriptor
>
<
telerik:CategoricalSeriesDescriptor
ItemsSourcePath
=
"SensorData"
>
<
telerik:CategoricalSeriesDescriptor.Style
>
<
Style
TargetType
=
"telerik:LineSeries"
BasedOn
=
"{StaticResource {x:Type telerik:LineSeries}}"
>
<
Setter
Property
=
"ValueBinding"
Value
=
"{StaticResource SensorValue2Binding}"
/>
<
Setter
Property
=
"VerticalAxis"
Value
=
"{StaticResource Value2Axis}"
/>
</
Style
>
</
telerik:CategoricalSeriesDescriptor.Style
>
</
telerik:CategoricalSeriesDescriptor
>
</
local:MySeriesDescriptorSelector.Value2SeriesDescriptor
>
</
local:MySeriesDescriptorSelector
>
</
telerik:ChartSeriesProvider.SeriesDescriptorSelector
>
</
telerik:ChartSeriesProvider
>
</
telerik:RadCartesianChart.SeriesProvider
>
Any suggestions? Or is my only option to extract my Value1 and Value2 properties into separate lists?
https://marketplace.visualstudio.com/items?itemName=vs-publisher-443.TelerikUIforWPF
vs
https://marketplace.visualstudio.com/items?itemName=TelerikInc.TelerikWPFVSExtensions