Telerik Forums
UI for WPF Forum
1 answer
90 views

Hi,

I'm talking about class "Slot" in Telerik.Windows.Controls.ScheduleView namespace.

Let's take a look to Slot(IOccurrence occurence) constructor, line 14 may cause NullReferenceException:

01.public Slot(IOccurrence occurence) : base(occurence)
02.        {
03.            IAppointment appointment = occurence as IAppointment;
04.            if (appointment != null)
05.            {
06.                if (appointment.RecurrenceRule != null)
07.                {
08.                    this.RecurrencePattern = appointment.RecurrenceRule.Pattern;
09.                }
10.            }
11.            else
12.            {
13.                Occurrence occurrence = occurence as Occurrence;
14.                appointment = occurrence.Appointment;
15.                if (occurrence != null)
16.                {
17.                    appointment = occurrence.Appointment;
18.                }
19.            }
20.            this.TimeZone = appointment.TimeZone;
21.            this.Resources.AddRange(appointment.Resources);
22.        }
Kalin
Telerik team
 answered on 25 Apr 2017
4 answers
650 views

Using the sample below, how would I get the "VendorName" property to display next to the values of each series in the trackball info popup, just like it would appear in the legend?

 

<telerik:RadCartesianChart x:Name="chart" Palette="Summer" Height="209">
 
           <telerik:RadCartesianChart.HorizontalAxis>
               <telerik:CategoricalAxis></telerik:CategoricalAxis>
           </telerik:RadCartesianChart.HorizontalAxis>
 
           <telerik:RadCartesianChart.VerticalAxis>
               <telerik:LinearAxis HorizontalAlignment="Right"></telerik:LinearAxis>
           </telerik:RadCartesianChart.VerticalAxis>
 
           <telerik:RadCartesianChart.Behaviors>
               <telerik:ChartTrackBallBehavior ShowTrackInfo="True"
                                          ShowIntersectionPoints="True" />
           </telerik:RadCartesianChart.Behaviors>
            
           <telerik:RadCartesianChart.SeriesProvider>
               <telerik:ChartSeriesProvider Source="{Binding ElementName=window1, Path=vendorSalesByYear}">
                   <telerik:ChartSeriesProvider.SeriesDescriptors>
 
                       <telerik:CategoricalSeriesDescriptor ItemsSourcePath="Data" ValuePath="Sales" CategoryPath="MonthName">
                           <telerik:CategoricalSeriesDescriptor.Style>
                               <Style TargetType="telerik:LineSeries">
                                   <Setter Property="LegendSettings">
                                       <Setter.Value>
                                           <telerik:SeriesLegendSettings Title="{Binding VendorName}"/>
                                       </Setter.Value>
                                   </Setter>
                                    
                                   <Setter Property="TrackBallInfoTemplate">
                                       <Setter.Value>
                                           <DataTemplate>
 
                                               <StackPanel Background="White">
                                                   <StackPanel Orientation="Horizontal" Background="Transparent">
                                                       <TextBlock Text="{Binding  VendorName}" />
                                                       <TextBlock Text=": "/>
                                                       <TextBlock Text="{Binding Path=DataPoint.Value, StringFormat=N0}" />
                                                   </StackPanel>
 
                                               </StackPanel>
 
                                           </DataTemplate>
                                       </Setter.Value>
                                   </Setter>
                                    
                               </Style>
                           </telerik:CategoricalSeriesDescriptor.Style>
                       </telerik:CategoricalSeriesDescriptor>
 
                   </telerik:ChartSeriesProvider.SeriesDescriptors>
               </telerik:ChartSeriesProvider>
 
           </telerik:RadCartesianChart.SeriesProvider>
       </telerik:RadCartesianChart>
 
       <telerik:RadLegend Items="{Binding LegendItems, ElementName=chart}" Margin="5" >
           <telerik:RadLegend.ItemsPanel>
               <ItemsPanelTemplate>
                   <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" />
               </ItemsPanelTemplate>
           </telerik:RadLegend.ItemsPanel>
 
       </telerik:RadLegend>

 

public  partial class MainWindow : Window
    {
        public RadObservableCollection<VendorYearlyData> vendorSalesByYear { get; set; }
 
        public MainWindow()
        {
            vendorSalesByYear = GetSampleData();           
            InitializeComponent();       
        }
 
        private RadObservableCollection<VendorYearlyData> GetSampleData()
        {
            var result = new RadObservableCollection<VendorYearlyData>();
 
            result.Add(new VendorYearlyData()
            {
                VendorName = "Vendor A",
                Data = new RadObservableCollection<SalesInfo>()
            {
                new SalesInfo() { MonthName = "Jan", Sales = 5 },
                new SalesInfo() { MonthName = "Feb", Sales = 7 },
                new SalesInfo() { MonthName = "Mar", Sales = 6 },
                new SalesInfo() { MonthName = "Apr", Sales = 8 }
            }
            });
 
            result.Add(new VendorYearlyData()
            {
                VendorName = "Vendor B",
                Data = new RadObservableCollection<SalesInfo>()
            {
                new SalesInfo() { MonthName = "Jan", Sales = 15 },
                new SalesInfo() { MonthName = "Feb", Sales = 18 },
                new SalesInfo() { MonthName = "Mar", Sales = 19 },
                new SalesInfo() { MonthName = "Apr", Sales = 23 }
            }
            });
 
 
            result.Add(new VendorYearlyData()
            {
                VendorName = "Vendor C",
                Data = new RadObservableCollection<SalesInfo>()
            {
                new SalesInfo() { MonthName = "Jan", Sales = 21 },
                new SalesInfo() { MonthName = "Feb", Sales = 25 },
                new SalesInfo() { MonthName = "Mar", Sales = 26 },
                new SalesInfo() { MonthName = "Apr", Sales = 25 }
            }
            });
 
            return result;
        }
    }
 
 
    public class SalesInfo
    {
        public string MonthName { get; set; }
        public double Sales { get; set; }
    }
 
    public class VendorYearlyData
    {
        public string VendorName { get; set; }
        public RadObservableCollection<SalesInfo> Data { get; set; }
    }

 

Martin Ivanov
Telerik team
 answered on 25 Apr 2017
1 answer
147 views
I would like to change alignment of text in header items. Is it possible ?
Martin Ivanov
Telerik team
 answered on 25 Apr 2017
4 answers
614 views

I have a question about Telerik UI for WPF, i want to achieve a number of real-time monitoring curve, here is my code:

XAML:  in UserControl)

<telerik:RadCartesianChart.SeriesProvider>

                    <telerik:ChartSeriesProvider Source="{Binding CurrentProject.CurrentSubProject.LineSeriesCollection}">
                        <telerik:ChartSeriesProvider.SeriesDescriptors>
                            <telerik:CategoricalSeriesDescriptor ItemsSourcePath="Points" ValuePath="Sales" CategoryPath="Time">
                                <telerik:CategoricalSeriesDescriptor.Style>
                                    <Style TargetType="telerik:LineSeries">
                                        <Setter Property="StrokeThickness" Value="2"/>
                                    </Style>
                                </telerik:CategoricalSeriesDescriptor.Style>
                            </telerik:CategoricalSeriesDescriptor>
                        </telerik:ChartSeriesProvider.SeriesDescriptors>
                    </telerik:ChartSeriesProvider>
                </telerik:RadCartesianChart.SeriesProvider>

 

Model:

        private ObservableCollection<Line> _lineSeriesCollection = new ObservableCollection<Line>() { };

        /// <summary>
        /// 界面中线条集合的Model
        /// </summary>
        public ObservableCollection<Line> LineSeriesCollection
        {
            get
            {
               
                if (_lineSeriesCollection.Count == 0)
                {
                    _lineSeriesCollection.Add(new Line(0, 15));
                    _lineSeriesCollection.Add(new Line(10, 25));
                    _lineSeriesCollection.Add(new Line(20, 35));
                    _lineSeriesCollection.Add(new Line(30, 50));
                }


                return _lineSeriesCollection;
            }
        }

 

///////Line Class:

    /// <summary>
    /// 界面的线条集合Model
    /// 20170417
    /// </summary>
    public class Line : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members

        [field: NonSerialized]
        public event PropertyChangedEventHandler PropertyChanged;
        public virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyName));
        }



        #endregion
        /// <summary>
        /// 用于存储当前线条的数据信息(组件名称+组件次序+输出参数)
        /// </summary>
        public string[] SelectedComponentInfo=new string[3];
        /// <summary>
        /// 用于存储线条中点数据的单位
        /// </summary>
        public string Unit;
       
        private ObservableCollection<ShowRealTimePoint> _points = new ObservableCollection<ShowRealTimePoint>();
        /// <summary>
        ///线条集合
        /// </summary>
        public ObservableCollection<ShowRealTimePoint> Points
        {
            get
            {
                return _points;
            }

            set
            {
                if (_points != value)
                {
                    _points = value;
                    OnPropertyChanged("Points");
                }
            }
        }


        private int minRange;
        private int maxRange;
        private System.Timers.Timer timer;
        public Line(int minRange, int maxRange)
        {
            this._points = new ObservableCollection<ShowRealTimePoint>();

            this.minRange = minRange;
            this.maxRange = maxRange;

            this.timer = new System.Timers.Timer();
            this.timer.Interval = 1000;
            this.timer.Elapsed += this.Timer_Elapsed;
            this.timer.Start();
        }





      private static Random r = new Random();
        private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() =>
            {
                if (this.Points.Count > 50)
                {
                    this.Points.RemoveAt(0);
                }
                this.Points.Add(new ShowRealTimePoint { Time = DateTime.Now, ParamValue = r.Next(0,100), });
            }));
        }

    }

///////ShowRealTimePoint Class:properties:Time ,ParamValue 

Actually, I'm referring to your example,but I cannot achieve the goal(my English is not good)

I ask you to help me see what the problem is,

Thank you very much.!!

 

 

 

 

Martin Ivanov
Telerik team
 answered on 25 Apr 2017
5 answers
777 views

I am using a style to color gridview column headers when a filter is applied to the gridview or when it is removed to change the color back to the default.  I save filters etc. using the persistence manager.  When I reload the gridview settings via the persistence manager the Filtered event does not fire. Is there a method that would replicate the adding of the filter or am I able to iterate the columns collection to identify the filtered columns?

 

Regards,

Joe

Stefan Nenchev
Telerik team
 answered on 25 Apr 2017
3 answers
303 views

So I have two gridsplitters in my app and I want to persist wherever the user drags them across sessions.  This mostly works but sometimes I seem to get this error whilst I am moving a gridsplitter and it locks and crashes the app:

An infinite loop appears to have resulted from repeatedly invalidating the TimeManager during the Layout/Render process

I don't know if this is a wild goose chase with the gridsplitters, but whenever I go back into the app, the gridsplitter positions revert back to their default positions and I haven't noticed it happen with any of the other controls that use the persistence framework.

 

So on my usercontrol with both gridsplitters I have the following code :

ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(RadGridView), new GridViewCustomPropertyProvider());
SplitterCustomPropertyProvider splitterPropProvider = new SplitterCustomPropertyProvider();
 
ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(RowDefinition), splitterPropProvider);
ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(ColumnDefinition), splitterPropProvider);

 

SplitterCustomPropertyProvider is as so:

public class SplitterCustomPropertyProvider : ICustomPropertyProvider
 {
   public CustomPropertyInfo[] GetCustomProperties()
   {
     // Create custom property to persist the pixels property on a column/row definition
     return new CustomPropertyInfo[]
     {
       new CustomPropertyInfo("GridSplitterPixels", typeof(double)),
     };
   }
 
   public void InitializeObject(object context)
   {
   }
 
   public object InitializeValue(CustomPropertyInfo customPropertyInfo, object context)
   {
     return null;
   }
 
   public object ProvideValue(CustomPropertyInfo customPropertyInfo, object context)
   {
     GridSplitterProxy proxy = new GridSplitterProxy();
     if (context is RowDefinition)
     {
       RowDefinition row = context as RowDefinition;
       proxy.Pixels = row.ActualHeight;
       return proxy;
     }
     else if (context is ColumnDefinition)
     {
       ColumnDefinition row = context as ColumnDefinition;
       proxy.Pixels = row.ActualWidth;
       return proxy;
     }
 
     return null;
   }
 
   public void RestoreValue(CustomPropertyInfo customPropertyInfo, object context, object value)
   {
     GridSplitterProxy proxy = value as GridSplitterProxy;
 
     if (context is RowDefinition)
     {
       RowDefinition row = context as RowDefinition;
       if (proxy.Pixels == 0)
         row.Height = new GridLength(1, GridUnitType.Auto);
       else
         row.Height = new GridLength(proxy.Pixels);       
     }
     else if (context is ColumnDefinition)
     {
       ColumnDefinition col = context as ColumnDefinition;
       if (proxy.Pixels == 0)
         col.Width = new GridLength(1, GridUnitType.Auto);
       else
         col.Width = new GridLength(proxy.Pixels);
     }
   }
 
   private class GridSplitterProxy
   {
     public double Pixels { get; set; }
   }
 }

 

The loading of the gridsplitter positions is done on the UserControl_Loaded event :

IsolatedStorageProvider isoStorageProvider = new IsolatedStorageProvider();
isoStorageProvider.LoadFromStorage();

And the saving of the positions is done on the MainWindow_Closing event :

IsolatedStorageProvider isoStorageProvider = new IsolatedStorageProvider();
isoStorageProvider.SaveToStorage();

 

Any ideas as to why I'm getting this error?

 

 

 

Petar Mladenov
Telerik team
 answered on 25 Apr 2017
2 answers
126 views

We use the following code to put a filter on tree items which work great intially.

snip .....

TreeListView.FilterDescriptors.SuspendNotifications();
ClearFilters();

ApplyFilter(Reflector.GetProperty<ProjectReleaseLineViewModel>((line) => line.HasError).Name, true, FilterOperator.IsEqualTo);

snip ......

 

private void ClearFilters()
{
           foreach (var column in TreeListView.Columns.OfType<Telerik.Windows.Controls.GridViewBoundColumnBase>())
           {
                var filterControl = column.FilteringControl as ColumnFilterControl;
if (filterControl != null)
{
filterControl.Reset(column);
}
}
}

private void ApplyFilter(string member, object value, FilterOperator @operator = FilterOperator.IsEqualTo)
{
var filter = new CompositeFilterDescriptor();
filter.FilterDescriptors.Add(new FilterDescriptor(member, @operator, value));
var colum = TreeListView.Columns.OfType<GridViewBoundColumnBase>().Skip(2).First();
colum.DataControl.FilterDescriptors.Add(filter);
}

When performing this action the tree explands showing the lines which have errors.

The strange behaviour happens after that through the following actions.

- The use manually collapses the expanded items al the way to level zero

- Then the filter is cleared through the following code

 

 

Johan
Top achievements
Rank 1
 answered on 25 Apr 2017
1 answer
618 views

How to implement Telerik checkbox in WPF to trigger functions while still remembering original state?

I have a checkbox that when checked should exclude an item in a RadGridView while still remembering the state (of the item being included), so if (or when) a user unchecks the checkbox, the item is included back in the list within the RadGridView. Essentially setting the original data back when unchecked to revert back to original data.

Stefan
Telerik team
 answered on 24 Apr 2017
1 answer
187 views

Hi!

When I create a ConditionalDataTemplateSelector to use as CellTemplateSelector in a GridView, I have to specify the name of the field in my DataTemplateRule like this:

<telerik:ConditionalDataTemplateSelector x:Key="PriceSelectedSelector">
        <telerik:DataTemplateRule Condition="IsSelected = False OR IsSelected = null" Template="t1" />
        <telerik:DataTemplateRule Condition="IsSelected = True" Template="t2" />
</telerik:ConditionalDataTemplateSelector>

But if I have a lot of columns that are just true/false I have to create a new ConditionalTemplateSelector for each and every column. Is there a way to build this in a more general way like "If the value in this cell is true, take template t1" so I could use my ConditionalTemplateSelector on different columns regardless of the name of the field?

Regards
Heiko

Stefan Nenchev
Telerik team
 answered on 24 Apr 2017
1 answer
111 views

Dear Telerik Team,

I've been playing with TileList for a while and it seems like the items virtualization does not work despite it is using an items panel that *should* allow virtualization. the documentation does not state whether TileList does support virtualization (it does for few other controls).

Cheers, Greg

Stefan Nenchev
Telerik team
 answered on 24 Apr 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?