Telerik Forums
UI for WPF Forum
1 answer
137 views

Is it possible to connect the dots on the attached image?

I have a chart where the x-axis is time span and the y-axis is double.

On the x-axis I want to show every hour between the stating time span 0h 0 min to the ending time span 23h 59min.

So what I have done is to create a list with all y-axis datapoints and all steps of the x-axis.

Where there are no datapoints on the y-axis I set the double to NaN.

So what I want is to draw a line between the values that are not set to NaN. Or ofcourse if there is another way to resolve this.

 


Items = new List<CurveItPlotInfo>(); for (int i = 0; i < 23; i++) { if (vats.Any(x => x.Time.Hours == i)) { foreach (var item in vats.Where(x => x.Time.Hours == i)) { Items.Add(new CurveItPlotInfo { TimeSpanValue = item.Time, Value = ConvertToDouble(item.Value), }); } } else if (i == 23) { Items.Add(new CurveItPlotInfo { TimeSpanValue = TimeSpan.FromMinutes(1439), Value = Double.NaN, }); } else { Items.Add(new CurveItPlotInfo { TimeSpanValue = TimeSpan.FromHours(i), Value = Double.NaN, }); ; } }

 

public class CurveItPlotInfo : ViewModelBase
    {

        private double value;
        private TimeSpan timeSpanValue;

        public double Value
        {
            get { return value; }
            set { SetProperty(ref this.value, value); }
        }

        public TimeSpan TimeSpanValue { get => timeSpanValue; set { SetProperty(ref timeSpanValue, value); } }

    }

 


<telerik:RadCartesianChart x:Name="CurveItChart" 
                                   Loaded="CurveIt_Loaded"
                                   Grid.Row="0">
            
            <telerik:RadCartesianChart.SmartLabelsStrategy>
                <telerik:ChartSmartLabelsStrategy />
            </telerik:RadCartesianChart.SmartLabelsStrategy>
            
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis x:Name="verticalAxis" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" />
            </telerik:RadCartesianChart.VerticalAxis>
            
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:DateTimeCategoricalAxis x:Name="datetimeAxis" 
                                                 SmartLabelsMode="SmartStep"
                                                 MajorTickLength="15"
                                                 PlotMode="OnTicksPadded">
                    <telerik:DateTimeCategoricalAxis.LabelTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Converter={converters:TimeSpanFormatConverter}}" />
                        </DataTemplate>
                    </telerik:DateTimeCategoricalAxis.LabelTemplate>
                </telerik:DateTimeCategoricalAxis>
            </telerik:RadCartesianChart.HorizontalAxis>
            
            <telerik:RadCartesianChart.Series>
                <telerik:LineSeries ValueBinding="Value" CategoryBinding="TimeSpanValue" ItemsSource="{Binding Items}">

                    <telerik:LineSeries.PointTemplate>
                        <DataTemplate>
                            <Border BorderBrush="AliceBlue" BorderThickness="1" >
                                <Rectangle Width="15" Height="15" Fill="Black"
                                           MouseLeftButtonDown="Rectangle_MouseLeftButtonDown" />
                            </Border>
                        </DataTemplate>
                    </telerik:LineSeries.PointTemplate>

                </telerik:LineSeries>
                
            </telerik:RadCartesianChart.Series>
            
        </telerik:RadCartesianChart>

Fredrik
Top achievements
Rank 1
Veteran
Iron
 answered on 11 May 2021
1 answer
144 views

I have recently been developing a radtreeview and needed the facility to only drop inside a folder, therefore eliminating the requirement for drop before and after. The link above resolved this issue, thank you, though I can still see the graphical orange indicator (line with circle) which is associated with the drop position.

Is it possible to disable this indicator as well?

As an aside issue, it appears that I get highlighted textblocks remaining behind after moving nodes around see the attached image. Do you have advice as to what could cause this?

tree-image

Vladimir Stoyanov
Telerik team
 answered on 11 May 2021
2 answers
152 views

 

Hello,

I have a problem to get the SelectedItems from my radcombobox. I have created an attached property "SelectedItemsHelper" to use the "SelectedItems" property. As a template for the attached property, I 've used this blog post.

My SelectedItemsHelper

using System.Collections;
using System.Windows;
using Telerik.Windows.Controls;

namespace WpfAutoQuery
{
    public class SelectedItemsHelper
    {
        
        public static readonly DependencyProperty SelectedItemsProperty =
            DependencyProperty.RegisterAttached("SelectedItems", typeof(IList), typeof(SelectedItemsHelper), new FrameworkPropertyMetadata((IList)null, new PropertyChangedCallback(OnSelectedItemsChanged)));
              
        public static IList GetSelectedItems(DependencyObject d)
        {
            return (IList)d.GetValue(SelectedItemsProperty);
        }

        public static void SetSelectedItems(DependencyObject d, IList value)
        {
            d.SetValue(SelectedItemsProperty, value);
        }

        private static void OnSelectedItemsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var comboBox = sender as RadComboBox;
            if (comboBox != null)
            {                
                IList selectedItems = GetSelectedItems(comboBox);
                if(selectedItems != null)
                {
                    comboBox.SelectedItems.Clear();
                    foreach (var item in selectedItems)
                    {
                        comboBox.SelectedItems.Add(item);
                    }
                }
            }                               
        }
    }
}

My RadComboBox:

<telerik:RadComboBox Name="rcbSection" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" Margin="10" IsEditable="False"
                                       ItemsSource="{Binding Sections}" DisplayMemberPath="Line1" AllowMultipleSelection="True"  
                                       local:SelectedItemsHelper.SelectedItems="{Binding SelectedSections}">                                              
</telerik:RadComboBox>

My "SelectedSections" property in ViewModel

public ObservableCollection<Section> SelectedSections
            {
                get { return GetPropertyValue<ObservableCollection<Section>>(); }
                set { SetPropertyValue(value); }
            }

I have added a jpg, where you can see that i dont get my selected values... Does someone can help me? I dont know what i do wrong...

 

Vladimir Stoyanov
Telerik team
 answered on 07 May 2021
3 answers
1.3K+ views

Hello.

 

When we debug or Run the application it works fine but in output window so many lines are coming with warning 

 

 

 

System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='AlternativeBrush'; ResourceKey.HashCode='18573990'; ResourceKey.Type='Telerik.Windows.Controls.FluentResourceKey'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='AlternativeBrush'; ResourceKey.HashCode='18573990'; ResourceKey.Type='Telerik.Windows.Controls.FluentResourceKey'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='BasicBrush'; ResourceKey.HashCode='1723761'; ResourceKey.Type='Telerik.Windows.Controls.FluentResourceKey'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='MarkerBrush'; ResourceKey.HashCode='35310062'; ResourceKey.Type='Telerik.Windows.Controls.FluentResourceKey'

 

When an item is clicked on the parent grid view, the child grid view list is displayed.

Style is not used anywhere. This warning occurs at this time.

 

Implicit noxaml is in use and is version 2021.1.419.45. (Theme :Fluent)

 

 

Thanks.

Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
 answered on 07 May 2021
2 answers
667 views

Dear Team,

In old times i used this code to have a custom sort on a datagridview:

    Private Sub DG_RM_SortCompare(sender As Object, e As DataGridViewSortCompareEventArgs) Handles DG_RM.SortCompare
        '''' <summary>Gets or sets a value indicating the order in which the compared cells will be sorted.</summary>
        '''' <returns>Less than zero if the first cell will be sorted before the second cell; zero if the first cell and second cell have equivalent values; greater than zero if the second cell will be sorted before the first cell.</returns>
        If e.Column.Index > 2 Then
            Try
                If e.CellValue1 Is Nothing OrElse e.CellValue1.Equals(DBNull.Value) Then
                    If e.CellValue2 Is Nothing OrElse e.CellValue2.Equals(DBNull.Value) Then
                        e.SortResult = 0
                    Else
                        e.SortResult = 1
                    End If
                Else
                    If e.CellValue2 Is Nothing OrElse e.CellValue2.Equals(DBNull.Value) Then
                        e.SortResult = -1
                    Else
                        e.SortResult = DirectCast(e.CellValue1, IComparable).CompareTo(DirectCast(e.CellValue2, IComparable))
                    End If
                End If
                e.Handled = True

            Catch ex As Exception
                MsgBox(Err.Description)
                Close()
            End Try
        End If
    End Sub

Now i need to achieve the same in WPF radgridview.. I have columns, with positive integers, zeroes and NULLs too.

Basically if i order : NULLs come first , then zeroes, then numbers ASC.

In my case customer needs to see in this way: zeroes, positive numbers asc, and nulls at the end.

The datasource is a datatable passed to radgridview as itemsource, and the column names (and number of them) are always dynamic, so i cannot predefine them in the XAML section. Please help

Thanks!

Peter B. (Hungary)

 

Peter
Top achievements
Rank 1
Iron
Iron
 answered on 06 May 2021
1 answer
173 views

Hi,

We ended up giving up on this issue a while back, but we are back trying to solve it, and I am wondering if there is any new way that we could set the order that Containers appear in the diagram.

We have a RadDiagram with several rectangular containers which contains several hexagons inside of them. we can easily place the hexagons wherever we want, but we cannot assure that the containers are displayed in an order we want.

We can easily do that for shapes, however whenever we bind to the position of a container, the binding gets overridden with (0,-26).

What we want is to be able to display containers on the diagram, ordered by the container's display header. From Left to right, top to bottom. Is that possible?


This is roughly what we are using:


Diagram:

<RadDiagram 
                                                    MinWidth="500"
                                                    IsPanEnabled="True"
                                                    ContainerShapeStyle="{StaticResource ContainerStyle}"
                                                    ShapeStyle="{StaticResource ShapeStyle}"
                                                    Style="{StaticResource RadDiagramStyle}"
                                                    PreviewMouseMove="diagram_PreviewMouseMove"
                                                    Grid.Row="0"
                                                    telerik:DiagramSurface.IsVirtualizing="True"
                                                    ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                                                    ScrollViewer.VerticalScrollBarVisibility="Hidden"
                                                    Background="{DynamicResource RadDiagram_Base_Normal_Background}"
                                                    IsSnapToGridEnabled="False"
                                                    IsConnectorsManipulationEnabled="False"
                                                    SelectionMode="None"
                                                    IsSnapToItemsEnabled="False"
                                                    IsInformationAdornerVisible="False"
                                                    telerik:DiagramAnimations.IsPanAnimationEnabled="False"
                                                    telerik:DiagramAnimations.IsZoomAnimationEnabled="False"
                                                    IsZoomEnabled="True"
                                                    AllowDelete="False"
                                                    IsEditable="False"
                                                    AllowPaste="False"
                                                    Primitives:BackgroundGrid.IsGridVisible="False"
                                                    AutoLayout="False"
                                                    Primitives:BackgroundPageGrid.IsGridVisible="False"
                                                    GraphSource="{Binding Nodes, Mode=OneWay}"/>


Container Style:

<Style x:Key="ContainerStyle"
           TargetType="telerik:RadDiagramContainerShape"
           BasedOn="{StaticResource RadDiagramContainerShapeStyle}">
      <Setter Property="Position"
              Value="{Binding Position, Mode=TwoWay}" />
      <Setter Property="AllowDelete"
              Value="False"/>
      <Setter Property="IsCollapsible"
              Value="{Binding IsHidden, Mode=OneTime}"/>
      <Setter Property="CollapsedContent"
              Value=""/>
      <Setter Property="UseDefaultConnectors"
              Value="False"/>
      <Setter Property="UseGlidingConnector"
              Value="False"/>
      <Setter Property="IsConnectorsManipulationEnabled"
              Value="False"/>
      <Setter Property="IsEditable"
              Value="False"/>
      <Setter Property="IsRotationEnabled"
              Value="False"/>
      <Setter Property="IsResizingEnabled"
              Value="False"/>
      <Setter Property="AllowCut"
              Value="False"/>
      <Setter Property="IsDraggingEnabled"
              Value="False"/>
      <Setter Property="ToolTip"
              Value="{Binding Details}"/>
      <Setter Property="ToolTipService.IsEnabled"
              Value="False" />
      <Setter Property="Background"
              Value="Red"/>
      <Setter Property="HorizontalContentAlignment"
              Value="Left"/>
      <Setter Property="BorderBrush"
              Value="Transparent"/>
      <Setter Property="IsCollapsed"
              Value="{Binding IsHidden, Mode=TwoWay}"/>
      <Setter Property="ContentTemplate">
        <Setter.Value>
          <DataTemplate>
            <TextBlock x:Name="HeaderText"
                       Foreground="{DynamicResource FocusAttentionGroupForegroundBrush}"
                       Text="{Binding Content}"
                       Background="Transparent"/>
          </DataTemplate>
        </Setter.Value>
      </Setter>
    </Style>

Martin Ivanov
Telerik team
 answered on 06 May 2021
1 answer
127 views

hi,
How can I have a scroll map above the RadCartesianChart where I can show the area currently view in the graph as in the image attched?
image
Thank you
Luigi

Martin Ivanov
Telerik team
 answered on 05 May 2021
1 answer
441 views

Is it possible to set an background image for a RadCartesianChart.

Or change the stroke fill color depending on the value at the point?



<telerik:LineSeries.StrokeShapeStyle>
   <Style TargetType="Path">
        <Setter Property="Fill" Value="Red"></Setter>
   </Style>
</telerik:LineSeries.StrokeShapeStyle>

Martin Ivanov
Telerik team
 answered on 05 May 2021
1 answer
73 views

hello,

How can i show the percent in the pie slice, and show the DataItem.Category outside the pice slice. But Now the Percent display outside the pice slice as the DataItem.Category.

Thans!

 

                        <telerik:PieSeries.LabelDefinitions>
                            <telerik:ChartSeriesLabelDefinition Margin="-4 0 0 0">
                                <telerik:ChartSeriesLabelDefinition.Template>
                                    <DataTemplate>
                                        <StackPanel>
                                            <TextBlock Text="{Binding DataItem.Category}" HorizontalAlignment="Center" FontSize="14"/>
                                            <TextBlock Text="{Binding Percent, StringFormat=\{0:N\} %}" FontSize="14"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </telerik:ChartSeriesLabelDefinition.Template>
                            </telerik:ChartSeriesLabelDefinition>
                        </telerik:PieSeries.LabelDefinitions>
Martin Ivanov
Telerik team
 answered on 05 May 2021
5 answers
179 views

Hello.

When using the tooltip content separately, the namespace is shown together.

<telerik:RadButton Height="30" Width="30"
                   telerik:RadToolTipService.Placement="Mouse"
                   telerik:RadToolTipService.ShowDuration="5000">
    <telerik:RadButton.Content>
        <TextBlock Text="&#xE72C" FontFamily="Segoe MDL2 Assets"/>
    </telerik:RadButton.Content>
    <telerik:RadToolTipService.ToolTipContent>
        <telerik:RadToolTipContentView >
            <TextBlock Text="ToolTip Name"/>
        </telerik:RadToolTipContentView>
    </telerik:RadToolTipService.ToolTipContent>
</telerik:RadButton>

 

If I use telerik:RadToolTipService.ToolTipContent="Content" it looks correct.

However, the above source was selected because it should be different from the button font setting.

When telerik:RadToolTipContentView is deleted, only other namespaces are shown, textblock content is not.

 

Please check.

Thanks.

Martin Ivanov
Telerik team
 answered on 05 May 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?