<
Page.Resources
>
<
DataTemplate
DataType
=
"{x:Type local:ViewModelRasterElement}"
>
<
Border
BorderBrush
=
"#EFEFEF"
BorderThickness
=
"1"
telerikDragDrop:RadDragAndDropManager.AllowDrop
=
"True"
telerikDragDrop:RadDragAndDropManager.AllowDrag
=
"True"
>
<
TextBlock
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Center"
Text
=
"{Binding Bezeichnung}"
/>
</
Border
>
</
DataTemplate
>
<
DataTemplate
x:Key
=
"ApplicationDragTemplateTextbox"
>
<
TextBox
Width
=
"200"
Height
=
"20"
/>
</
DataTemplate
>
<
DataTemplate
x:Key
=
"ApplicationDragTemplateLabel"
>
<
Label
Background
=
"Yellow"
Content
=
"Ziehen Sie den in eine bliebige Zelle"
/>
</
DataTemplate
>
</
Page.Resources
>
<
ItemsControl
ItemsSource
=
"{Binding RasterElemente}"
>
<
ItemsControl.ItemContainerStyle
>
<
Style
>
<
Setter
Property
=
"Grid.Row"
Value
=
"{Binding GridRow}"
/>
<
Setter
Property
=
"Grid.Column"
Value
=
"{Binding GridColumn}"
/>
</
Style
>
</
ItemsControl.ItemContainerStyle
>
<
ItemsControl.ItemsPanel
>
<
ItemsPanelTemplate
>
<
Grid
ShowGridLines
=
"false"
telerikDragDrop:RadDragAndDropManager.AllowDrop
=
"True"
telerikDragDrop:RadDragAndDropManager.AllowDrag
=
"True"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"50"
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"130"
/>
<
ColumnDefinition
Width
=
"130"
/>
<
ColumnDefinition
Width
=
"130"
/>
<
ColumnDefinition
Width
=
"130"
/>
<
ColumnDefinition
Width
=
"130"
/>
<
ColumnDefinition
Width
=
"130"
/>
<
ColumnDefinition
Width
=
"130"
/>
<
ColumnDefinition
Width
=
"130"
/>
</
Grid.ColumnDefinitions
>
</
Grid
>
</
ItemsPanelTemplate
>
</
ItemsControl.ItemsPanel
>
</
ItemsControl
>
public
ViewTest()
{
InitializeComponent();
RadDragAndDropManager.AddDragQueryHandler(
this
, OnDragQuery);
RadDragAndDropManager.AddDropQueryHandler(
this
, OnDropQuery);
RadDragAndDropManager.AddDropInfoHandler(
this
, OnDropInfo);
}
private
void
OnDropInfo(
object
sender, DragDropEventArgs e)
{
Console.WriteLine(e.Options.Status);
if
(e.Options.Status == DragStatus.DropComplete)
{
string
typ = e.Options.Source.GetType().ToString();
switch
(typ)
{
case
"System.Windows.Controls.ListBox"
:
{
if
(e.Options.Payload !=
null
)
{
ViewModelRasterElement element = (ViewModelRasterElement)e.Options.Destination.DataContext;
element.Bezeichnung = e.Options.Payload.ToString();
}
}
break
;
default
:
break
;
}
}
e.Handled =
true
;
}
void
OnDropQuery(
object
sender, DragDropQueryEventArgs e)
{
Console.WriteLine(e.Options.Status);
Console.WriteLine(e.Options.Destination.DataContext.GetType().ToString());
if
(e.Options.Destination.DataContext
is
ViewModelRasterElement &&
e.Options.Status == DragStatus.DropDestinationQuery)
{
e.QueryResult =
true
;
}
e.Handled =
true
;
Console.WriteLine(e.QueryResult);
}
protected
virtual
void
OnDragQuery(
object
sender, DragDropQueryEventArgs e)
{
string
typ = e.Options.Source.GetType().ToString();
switch
(typ)
{
case
"System.Windows.Controls.ListBox"
:
{
ListBox listbox = (ListBox)e.Options.Source;
if
(listbox.SelectedItem !=
null
)
{
if
(e.Options.Status == DragStatus.DragQuery)
{
e.Options.Payload = listbox.SelectedItem;
ContentControl cue =
new
ContentControl();
cue.ContentTemplate =
this
.Resources[
"ApplicationDragTemplateLabel"
]
as
DataTemplate;
cue.Content = listbox.SelectedItem;
e.Options.DragCue = cue;
e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue();
}
}
}
break
;
default
:
break
;
}
e.Handled =
true
;
e.QueryResult =
true
;
}
Hi Petar, as we have discussed previously, my app receives data from remote sources and I add it to a chart in the elapsed event of a timer. The timer that updates the chart runs continuously however there are often periods of time when no data is received. For those periods I want to display the X axis label (i.e. the time) and a blank space where the bar should be. So, for long periods of time where no data is received the user should simply see the x axis labels scrolling to the left (no bars) as the chart is updated. Please note in my app that there are no series initially defined for my chart. The reason for that is that the series are linked to a property of the data and until I have data to display I don’t know what series to display.
Having said that, there are two issues which I would like to bring to your attention and attempt to resolve:
1.) When the application is first loaded there is no data and no series as described above. I add a series with Y values = 0 and X values containing time periods in the past (the labels on the X axis are time stamps). The purpose of adding this series is to overcome issues with bar width that I have asked about in prior posts, and also to act as a placeholder for time periods (bars) where there is no data. My intent is that the X axis labels should ALWAYS appear on the chart, but the bar fragments for this placeholder series should never appear on the chart (the Y values are always zero). The problem is that when there is no data there is no Y axis so the placeholder series is plotted at the full height of the chart even though the values are zero. How do I suppress plotting the bars for this series but keep the X axis labels? Ideally I would like a Y axis scale to always appear on the chart. If I could initially set that scale to have a max of, say, 1 that would cause the zero value placeholder series to have no height which would work just fine.
2.) When all data scrolls off the left side of the chart, new bars are not plotted when data is received. This issue can be reproduced as follows:
Load the attached app and click Start Generating Data.
Wait until a few bars are generated then click Stop Generating Data.
Wait until all bars have scrolled off the left side of the chart. Notice that the placeholder series is plotted at full height (this is the issue described above).
Click Start Generating Data. Notice that no bars are plotted.
Repeat the above steps but do not allow all data to scroll off the left side of the chart. When you click Start Generating Data again, data will plot as expected.
I found that adding a placeholder row in my data collection will work around this issue. Uncomment the following code in the AddLoadStatistic method. However I am not certain this is a fix, or perhaps I am doing something else that’s wrong that is causing this issue (???).
if (LoadSources.Count > 0)
{
foreach (System.Collections.DictionaryEntry key in LoadSources)
LoadStatistics.Add(new LoadStatistic { PeriodEnding = LoadIntervalEndTime, Source = key.Key.ToString() });
}
else
I have created a RadPanelBar with two items. I want the DefaultItem to be selected by default. How can I do that dynamically?
Below is the xaml code for RadPanelBar
<
telerik:RadPanelBar
x:Name
=
"mybar"
Width
=
"252"
Height
=
"500"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
ExpandMode
=
"Single"
Margin
=
"0,58,0,0"
SelectedItem
=
"{Binding PanelBarItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
>
<
telerik:RadPanelBarItem
x:Name
=
"DefaultItem"
>
<
telerik:RadPanelBarItem.Header
>
<
TextBlock
Text
=
"Default Item"
/>
</
telerik:RadPanelBarItem.Header
>
</
telerik:RadPanelBarItem
>
<
telerik:RadPanelBarItem
x:Name
=
"ExpandItem"
>
<
telerik:RadPanelBarItem.Header
>
<
TextBlock
Text
=
"Expand Item"
/>
</
telerik:RadPanelBarItem.Header
>
<
ListBox
Height
=
"200"
Margin
=
"1,17,1,143"
ItemsSource
=
"{Binding TList}"
BorderBrush
=
"Transparent"
BorderThickness
=
"0"
SelectedItem
=
"{Binding SelectedTool, Mode=TwoWay}"
>
</
ListBox
>
</
telerik:RadPanelBarItem
>
</
telerik:RadPanelBar
>
I also want the first item in the TList to be selected by default when ExpandItem is selected. Please help with this.
Thanks in Advance