Telerik Forums
UI for WPF Forum
5 answers
150 views

Before export to Excel we add aggregate function:

var sumFunction = new CountFunction()
{
ResultFormatString = " ({0} items): "
};
column.AggregateFunctions.Add(sumFunction);

Export functionality:

var options = new GridViewExportOptions
{
Format = ExportFormat.ExcelML,
ShowColumnHeaders = true,
ShowColumnFooters = true,
ShowGroupFooters = true,
Encoding = Encoding.UTF8
};

var fileToExportTo = exportFileInfo.FullName;
using (FileStream fs = new FileStream(fileToExportTo, FileMode.OpenOrCreate))
{
gridControl.Export(fs, options);
}

Exception: Object reference not set to an instance of an object.

   at Telerik.Windows.Controls.GridViewBoundColumnBase.<>c__DisplayClass18.<Telerik.Windows.Controls.IExportableColumn.GetCellContent>b__12(AggregateFunction f) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Columns\GridViewBoundColumnBase.cs:line 55
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Telerik.Windows.Controls.GridViewBoundColumnBase.Telerik.Windows.Controls.IExportableColumn.GetCellContent(Object parameter) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Columns\GridViewBoundColumnBase.cs:line 56
   at Telerik.Windows.Controls.GridViewExportWriter.RenderHeaderOrFooterCells(ExportElement element, Object context) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewExportWriter.cs:line 692
   at Telerik.Windows.Controls.GridViewExportWriter.RenderFooterRow() in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewExportWriter.cs:line 535
   at Telerik.Windows.Controls.GridViewExportWriter.Render() in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewExportWriter.cs:line 101
   at Telerik.Windows.Controls.GridView.GridViewDataControl.Export(Stream stream, GridViewExportOptions options) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewDataControl.Exporting.cs:line 31

Maya
Telerik team
 answered on 09 Jun 2015
1 answer
177 views

I have an annotation on my timeline which I want to move up/down in time.

I know I can just change the annotations Date to do this, but How can I get the user to interact with the annotation.

It does not trigger the SelectionChanged event (cos it's not a item).

Is there a way to identify it the mouse down, move and up events, so I can calculate it's new Date value there??

Martin Ivanov
Telerik team
 answered on 09 Jun 2015
7 answers
159 views
I am using the Q3 2014 SP1 version. I enabled clustering, which works. However, for the first load, all pinpoints are clustered even when there is only one point in the area. If I zoom in/out, the clustering fixes itself and the pinpoint is shown correctly instead of showing as a cluster of one point. Any ideas? I would provide a sample, but right now I just don't have the time.
Petar Mladenov
Telerik team
 answered on 09 Jun 2015
2 answers
73 views

Hi Team,

 

I am using Telerik grid. I am able edit data in the telerik grid cells.If i want to save the edited data, I am facing an issue.

Example: First cell i entered data and press Save button it is not taking edited cell value.If i move to the second cell then only first cell data was saveing.

Can you please check and help me here.

 

Please find attcahed attcahed xaml file.

 

Thanks,
Siva

Siva
Top achievements
Rank 1
 answered on 09 Jun 2015
1 answer
123 views

Hi,

 I am using RadScheduleView to display multiple calendars, I have defined group filter function in my view model and it is binded to the view definition in XAML, When I select resources and add a new calendar first time the group filter function gets called 9 times, I have just 4 resources + date group, Second time it gets called like 100 times and the application hangs. Is this a issue in group filter or am i doing something wrong.

 Thanks

vikas

 

_departmentResourceType.Resources.Add(new Resource("Department - 1", "Department"));
            _departmentResourceType.Resources.Add(new Resource("Department - 2", "Department"));            

            _locationResourceType.Resources.Add(new Resource("Location - 1", "Location"));
            _locationResourceType.Resources.Add(new Resource("Location - 2", "Location"));

            _allResourceTypes.Add(_departmentResourceType);
            _allResourceTypes.Add(_locationResourceType);

Vikas
Top achievements
Rank 1
 answered on 08 Jun 2015
3 answers
458 views

Hello,

I have a question about traversing the focus when a selection is made in the RadComboBox.

I have the following requirement:

When the user enters the combobox, the drop down should automatically open (I set OpenDropDownOnFocus= true) , the user will select an item and confirm the selection by using the enter key. After that the item should be set, the drop down should be closed and the focus should automatically traverse to the next field. Travesersing focus to the next field should be done by the enter-key, I already implemented this for textboxes.

 

I have used below code with the regular WPF ComboBox, but this gave some unexpected behavior in the past.

Sometimes the warning was shown ("Couldn't move the focus.......) and the user was not able anymore to traverse the focus in the whole screen using the enter key, he needed to close the screen and open it again to re-enable this functionality.

 

public class CustomComboBox : ComboBox
{
    #region Fields
 
    private bool _focused = false;
 
    #endregion
 
    #region Methods
 
    protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
    {
        base.OnGotKeyboardFocus(e);
 
        _focused = true;
    }
 
    protected override void OnDropDownClosed(EventArgs e)
    {
        if (_focused)
        {
            var uie = this as UIElement;
 
            _focused = false;
        }
        else
        {
            base.OnDropDownClosed(e);
        }
    }
 
    protected override void OnKeyDown(KeyEventArgs e)
    {
        if ((e.Key == System.Windows.Input.Key.Enter))
        {
            base.OnKeyDown(e);
 
 
            var comboBoxItem = e.OriginalSource as FrameworkElement;
            var comboBox = ItemsControl.ItemsControlFromItemContainer(comboBoxItem) as ComboBox;
 
            if (comboBox != null)
                comboBox.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
            else
            {
                LogManager.GetLog(this.GetType()).Warn("Couldn't move the focus to the next field, source: {0}.", e.OriginalSource);
            }
        }
        else
            base.OnKeyDown(e);
 
    }
    #endregion
}

 

 What is the best way to accomplish this, or is this functionality already in the RadComboBox?

 

Regards,

 

Marcel

Nasko
Telerik team
 answered on 08 Jun 2015
1 answer
433 views

I'm in need to display a RadListBox with some Items as ItemsSource. Those items are of type DataFieldOption and the have properties ID (int) and Name (string).

Here are some examples:

DataFieldOption 1: ID = 184, Name = "German"

DataFieldOption 2: ID = 185, Name = "English"

DataFieldOption 3: ID = 186, Name = "French"

...

 

The SelectionMode of my ListBox is Multiple. I already read the Telerik blog about how to handle the SelectedItems property so I created the necessary helper class and named it ListBoxSelectedItemsHelper.

 

public class ListBoxSelectedItemsHelper
    {
        #region Fields
 
        public static readonly DependencyProperty SelectedItemsProperty;
 
        #endregion
 
        #region Constructors
 
        static ListBoxSelectedItemsHelper()
        {
            SelectedItemsProperty = DependencyProperty.RegisterAttached("SelectedItems", typeof(IList), typeof(ListBoxSelectedItemsHelper), new FrameworkPropertyMetadata(null, OnSelectedItemsChanged));
        }
 
        #endregion
 
        #region Methods
 
        #region DependencyProperty Methods
 
        #region CallBack
         
        private static void OnSelectedItemsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var listBox = sender as RadListBox;
 
            if (listBox != null)
            {
                IList selectedItems = GetSelectedItems(listBox);
 
                if (selectedItems != null)
                {
                    listBox.SelectedItems.Clear();
 
                    foreach (var item in selectedItems)
                    {
                        listBox.SelectedItems.Add(item);
                    }
                }
            }
        }
 
        #endregion
 
        #region Getter/Setter
 
        public static IList GetSelectedItems(DependencyObject d)
        {
            return (IList) d.GetValue(SelectedItemsProperty);
        }
 
        public static void SetSelectedItems(DependencyObject d, IList value)
        {
            d.SetValue(SelectedItemsProperty, value);
        }
 
        #endregion
 
        #endregion
 
        #endregion

 

I must use this ListBox inside RadDataForm and I need to get the ListBox' selected items as one single string value with the help of a converter. So if three ListBox entries are selected SelectedItems will become an ObservableCollection with three objects in it. This is achieved by using the helper class from above. Now it's getting tricky. I want to use a converter that converts that ObservableCollection to a string value. Looking at the example values at the begining of my post this means: If German and French are selected in the ListBox, SelectedItems becomes ObservableCollection with two objects and this should get converted to "184;186" (the objects IDs separated by ';').

 Here is my converter (it already works):

public class DataFieldOptionConverter : DependencyObject, IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length == 2)
            {
                var dataFieldOptions = values[0] as IList<IDataFieldOptionDataItemViewModel>;
                var stringValue = values[1] as string;
 
                //
                if (dataFieldOptions != null && String.IsNullOrEmpty(stringValue) == false)
                {
                    var parts = stringValue.Split(';');
 
                    if (parts.Any())
                    {
                        var result = new List<IDataFieldOptionDataItemViewModel>();
 
                        foreach (var part in parts)
                        {
                            var dfo = dataFieldOptions.SingleOrDefault(x => (System.Convert.ToString(x.ID) == part));
 
                            if (dfo != null)
                            {
                                result.Add(dfo);
                            }
                        }
 
                        return result;
                    }
                }
            }
 
            // Konvertierung fehlgeschlagen
            return DependencyProperty.UnsetValue;
        }

 

It is a MultiValueConverter to pass in a list of all selectable items (see type DataFieldOption above) and a string value of format "184;186" to check which items are selected. This is my XAML code:

<t:DataFormDataField Label="{Binding DataField.Label, Mode=OneWay}" Description="{Binding DataField.ToolTip, Mode=OneWay}" DataMemberBinding="{Binding Value, Mode=OneWay}">
  <tx:CustomRadListBox ItemsSource="{Binding DataField.DataFieldOptions, Mode=OneWay}" DisplayMemberPath="Name" SelectedValuePath="ID" SelectionMode="Multiple">
    <tx:ListBoxSelectedItemsHelper.SelectedItems>
      <MultiBinding Converter="{StaticResource DataFieldOptionConverter}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
        <Binding Path="DataField.DataFieldOptions" />
        <Binding Path="Value" />
      </MultiBinding>
    </tx:ListBoxSelectedItemsHelper.SelectedItems>
  </tx:CustomRadListBox>
</t:DataFormDataField>

 

 

I tried to get this to work for days now and I'm really running out of ideas. What I need is a RadListBox with SelectionMode = multiple and I want to save the users selection as a single string value in a database. Later that value is read from the database (for example "184;186;188") and it has to be converted back to a list of selected items so the ListBox gets back to its saved state. And all this inside RadDataForm. Can you provide any help on this?

Johannes
Top achievements
Rank 1
 answered on 08 Jun 2015
1 answer
96 views

I am building a custom control that inherits RadDatePicker and overrides the OnParseDateTime method to implement custom parsing logic. One of the requirements of this logic is being able to parse a date in the MM/dd/yy format. Unfortunately, whenever a date is entered in that format, the control changes the CurrentDateTimeText, but not the DateTimeText, and thus the ParseDateTimeValue event is never raised.

 

What's curious is that I have a similar control (derived from RadDateTimePicker) that accepts that format and raises the ParseDateTimeValue event as expected, even without a time value. However, if its InputMode is changed to "DatePicker", then it will no longer parse dates with a two-digit year.

 

Is this a known bug, or am I missing something?

Geri
Telerik team
 answered on 08 Jun 2015
7 answers
112 views

Hi I am using RadGridView 4.0 for one of my application.

It was building successfully but at run-time I am getting exception - 'Set connection Id ...' , when I get into detail it is saying 

Could not load file or assembly 'Telerik.Windows.Data, Version=2013.3.1016.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The system cannot find the file specified.

I am using the libraries from nuget package for WPF 4.0 [ RadControls.for.Wpf.40.2013.3.1016] - All same versions

Telerik.Windows.Controls

Telerik.Windows.Controls.GridView

Telerik.Windows.Controls.Input

Telerik.Windows.Controls.Navigation

Telerik.Windows.Data

 

Please respond ASAP as we have start UAT for our application, and it is giving errors on forms with telerik radgridview.

 We are a licensed User of Telerik with customer Id ZS1376728

 

Quick Resolution Required or we have to switch to standard datagrid

 

Thanks & Regards,

Vikas Sharma

Maya
Telerik team
 answered on 08 Jun 2015
1 answer
131 views

Hi

I have the radial menu working as a standalone and can see how it works as a context menu to an element, but how do I define the context menu so it can be used by many elements of the same type.

In my app the user can double click on one of 20 items, some items are of the same type, say some are 'apples' and some are 'oranges', theses elements are added to visual tree in code, when the user double clicks one I want to be able to determine the items type and then display the correct radial menu as a context menu.

I have seen examples for other platforms, but the WPF docs do not cover this functionality.

Georgi
Telerik team
 answered on 05 Jun 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?