Telerik Forums
UI for WPF Forum
3 answers
150 views
Hi,

I'm testing out this library and I'm getting the following error:
No method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied arguments.

I'm doing a very simple test. Here is the relevant code:

public class Data     
{     
    public UInt32 XValue { getset; }     
    public double YValue { getset; }     
}     
    
List<Data> m_Data; // This is initialized with data.     
    
// Then, when setting up the chart...     
    
SeriesMapping seriesMapping = new SeriesMapping();     
LineSeriesDefinition lineDefinition = new LineSeriesDefinition();     
lineDefinition.ShowItemLabels = false;     
seriesMapping.SeriesDefinition = lineDefinition;     
seriesMapping.ItemMappings.Add(new ItemMapping("XValue", DataPointMember.XValue));  
seriesMapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue));     
MyChart.SeriesMappings.Add(seriesMapping);     
    
// Then I set my data     
MyChart.ItemSource = m_Data; 

When m_Data has more then 397 elements it throws that error. Before that number it looks pretty.

Any help will be greatly appreciated.
- Luis
Ves
Telerik team
 answered on 09 Jul 2010
3 answers
172 views
Is it possible to show a value that is not part of the ItemsSource of the combobox? My observablecollection contains 1,2,3,4, but the value I have assigned to the databound field is 10.

Below is my current column setup.
<telerik:GridViewComboBoxColumn Header="Weld ID" x:Name="ddWeldID" DataMemberBinding="{Binding WeldID}" DisplayMemberPath="WeldID" SelectedValueMemberPath="WeldID" 
                                                    IsComboBoxEditable="True" /> 


WeldID contains the value 24, but the ItemsSource I bind to the combobox contains the values 1,2,3,4. When I load the grid, 24 is not displayed in the column, but if I add the value 24 as one of the dropdown options, it gets displayed in the column.

Any help would be much appreciated!

Ryan
Pavel Pavlov
Telerik team
 answered on 09 Jul 2010
2 answers
155 views
Hi,

Instead of the more usual technical question, this post is related to functional requirements, and choosing among different implementations. I hope I can keep it as short as possible, not too philosophical, and of course, raise interest/curiosity among some of you ;-)

We are currently building a Framework in order to ease and speed up the development of certain kind of applications. We have decided to create a custom control library (using telerik as base) that must fulfill the following requirementes:

1.- Provide just the properties/events (Controls) that we consider necessary. --hiding attributes--
2.- Extend the base controls in order to add extra functionallity. --creating new attributes--
3.- Ease the implementation of our interfaces. By dragging a control from the VisualStudio (or Blend) designer toolbox to the window/page/usercontrol/etc, the developer will have most of the necessary attributes (see req. 1) with the proper default values.
4.- The controls must support all the standard (graphic) features of WPF: Styling, Control Templates, Storyboards, etc.
5.- The controls must support standard event handling, although we might use a fancier action/commanding approach (like the ones implemented by Prism, or Caliburn)
6.- DataBindings.

After some research, we came up with three solutions (summarized, as I'm trying to keep this as short as possible):

A) Wrapping the control: using Control as base class, we add the telerik control as the first (and only) visual child. Then we create a DependencyProperty for each DP we want to expose from the telerik control.
public class MyComboBox : MyBaseControl  
{  
    static MyComboBox()  
    {  
        DefaultStyleKeyProperty.OverrideMetadata(typeof(MyComboBox), new FrameworkPropertyMetadata(typeof(MyComboBox)));  
  
        RegisterDependencyProperties(typeof(MyComboBox), typeof(RadComboBox));  
    }  
  
    public MyComboBox()  
    {  
        InternalFrameworkElement = new RadButton();  
  
        this.AddVisualChild(InternalFrameworkElement);  
    }  
    protected override int VisualChildrenCount  
    {  
        get  
        {  
            return InternalFrameworkElement == null ? 0 : 1;  
        }  
    }  
    protected override Visual GetVisualChild(int index)  
    {  
        if (InternalFrameworkElement == null)  
        {  
            throw new ArgumentOutOfRangeException();  
        }  
        return InternalFrameworkElement;  
    }  
    private RadComboBox ComboBox  
    {  
        get  
        {  
            return InternalFrameworkElement as RadComboBox;  
        }  
    }  
    public IEnumerable ItemsSource  
    {  
        get { return (IEnumerable)GetValue(ItemsSourceProperty); }  
        set { SetValue(ItemsSourceProperty, value); }  
    }  
  
    public static readonly DependencyProperty ItemsSourceProperty =  
        DependencyProperty.Register(  
            "ItemsSource"typeof(IEnumerable), typeof(MyComboBox),  
            new FrameworkPropertyMetadata  
            {  
                PropertyChangedCallback = (obj, e) =>  
                {  
                    (obj as MyComboBox).UpdateItemsSource((IEnumerable)e.NewValue);  
                }  
            });  
  
    private void UpdateItemsSource(IEnumerable sel)  
    {  
        ComboBox.ItemsSource = sel;  
    }  
}  
 
(its much more elaborated, and I didn't copy all the code, but you get the basic idea)

B) Control templating: using Control as base class, we redefine the default styles of each control. The template (ControlTemplate) property is assigned to the telerik control. Then we create a TemplateBinding (or complete Binding, depends...) for each DP we want to expose. The DP is also created in the Control:
<Setter Property="Template">  
    <Setter.Value>  
        <ControlTemplate TargetType="{x:Type local:MyComboBox}">  
            <ControlsInput:RadComboBox Name="PART_MyComboBox"  
                BorderBrush="{TemplateBinding Property=BorderBrush}"  
                BorderThickness="{TemplateBinding Property=BorderThickness}"  
                Background="{TemplateBinding Property=Background}"  
                Foreground="{TemplateBinding Property=Foreground}"  
                SelectionBoxTemplate="{TemplateBinding Property=SelectionBoxTemplate}"  
                ItemTemplate="{TemplateBinding Property=ItemTemplate}"  
                SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor,   
                AncestorType={x:Type local:MyComboBox}}, Path=SelectedItem}"  
                ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor,   
                AncestorType={x:Type local:MyComboBox}}, Path=ItemsSource}">  
            </ControlsInput:RadComboBox>  
        </ControlTemplate>  
    </Setter.Value>  
</Setter>  
(again, its much more elaborated)

C) Directly inheriting the telerik control. (we loose the req. 1, hiding attributes)

public class MyComboBox : RadComboBox  
{  
    static MyComboBox()  
    {  
        DefaultStyleKeyProperty.OverrideMetadata(typeof(MyComboBox), new FrameworkPropertyMetadata(typeof(MyComboBox)));  
    }  
}  


In summary:
- Solution A (wrapper) is somehow ugly, and uses a lot of tricks in order to do things such as:
    - Creating data bindings (from XAML)
    - Using CustomTemplates (from the final developer point of view)
    - Create data bindings from code behind.

- Solution B is more elegant (they are pretty much the same thing, as they generate the same logical tree for each control), but I'm not sure how difficult it will be to wrap complex controls, such as the GridView, Ribbon, etc.

- Solution C basically breaks with one of the initial requirements, but its still a valid approach. Besides, you can somehow suggest what properties to use by implementing the Extensibility Model for the WPF Designer.

My questions are:

    * What is the best approach, given the scenario I exposed?
    * Any other ideas/suggestions?


By the way, we need to provide the same control libraries for Silverlight and ASP.net, and it would be nice to use the same approach, at least with WPF and SL.

Thanks,


--
R.
Roberto
Top achievements
Rank 1
 answered on 09 Jul 2010
1 answer
121 views
I am using a GridView with RowDetails.
I have a GridViewSelectcolumn.
Now whenever I select a row( check the checkbox) the rowdetails is expanded.
I do not want the row details to expand when the checkbox is checked. It should only expand/collapse through GridViewToggleRowDetailsColumn +/-

How to achieve such functionality>
Milan
Telerik team
 answered on 09 Jul 2010
9 answers
500 views
I wish to filter data in a gridview upon clicking a button.
I do not want to include filtering under header column row.

P.S. I got it working


Yavor Georgiev
Telerik team
 answered on 08 Jul 2010
7 answers
165 views
I am running into an issue when using the Gridview. I have a Gridview which has the columns defined declaratively in the xaml. There are several controls such as buttons, checkboxes, etc... in the column definitions. I use the GridViewColumns as illustrated below:

                    <telerik:GridViewColumn> 
                                <telerik:GridViewColumn.CellTemplate> 
                                    <DataTemplate> 
                                        <CheckBox VerticalAlignment="Center" x:Name="NextQueue"></CheckBox> 
                                    </DataTemplate> 
                                </telerik:GridViewColumn.CellTemplate> 
                            </telerik:GridViewColumn> 

I set the commandparameters of these elements in the rowloaded event on the GridView. Everything works fine until I scroll the gridview. The rowloaded event throws multiple errors. It appears that several of the elements that are available when the row loaded event first fires are not available when the rowloaded event fires when the scrollbar is used. For example here is how I access one of the checkboxes in the rowloaded:

var row = e.Row as GridViewRow; 
 
var selectedButton = row.Cells[0].ChildrenOfType<CheckBox>()[0]; 
selectedButton.CommandParameter = targetDub; 

When this runs when the grid is initially loaded it works fine. As soon as the user scrolls the grid it throws an exception because the row.Cells[0].ChildrenOfType<CheckBox>() returns a count of 0. This is the case when I try to find any of the controls on that row.

What could be causing this?

Richard Averett
Top achievements
Rank 1
 answered on 08 Jul 2010
3 answers
188 views
Hello,

I recently switched my WPF app to use RadMenu and RadMenuItems. After making this change, I noticed a subtle difference in behavior.The problem is that when a new window is launched in response to a RadMenuitem click, it is immediately deactivated. I proved this by hooking the Deactivated event of the window I was opening. (See the stack trace below.)  I have confirmed that this problem is due to RadMenu/RadMenuItem  - changing back to WPF Menu/MenuItem made the problem go away. The deactivated window is a problem because immediately after launch users try to interact with the window, and there is a short delay to activate it again.

Background:
I have an MVVM WPF application. I open new windows by sending a message (mediator pattern) from the MainViewModel to the MainView. The MainView creates a new window, associates a view model to datacontext, and calls Show():

        ''' <summary> 
        ''' Handles displaying and replying to any received command messages 
        ''' </summary> 
        ''' <param name="message"></param> 
        ''' <remarks></remarks> 
        Private Sub HandleCommandMessage(ByVal message As CommandMessage) 
 
            If Not IsNothing(message) Then 'AndAlso message.Sender.GetType() Is GetType(MainViewModel) Then 
 
                ' Check if we are running on the UI thread. If not, call begin invoke 
                If Not _dispatcher.CheckAccess Then 
                    _dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, _ 
                                            New Action(Of CommandMessage)(AddressOf HandleCommandMessage), message) 
                Else 
                    Select Case message.Command 
 
                        Case Messages.ViewMessages.ShowDiagnosticsView.ToString() 
                            If IsNothing(_diagWindow) Then 
                                _diagWindow = New DiagnosticsView 
                                _diagWindow.Owner = Me 
                                _diagWindow.DataContext = Me.ViewModel.DiagViewModel 
                                _diagWindow.Show() 
                            End If 
 
                        Case Messages.ViewMessages.CloseDiagnosticView.ToString() 
                            If Not IsNothing(_diagWindow) Then 
                                _diagWindow.Close() 
                                _diagWindow = Nothing 
                            End If 
 
                       '... 
 
                        Case Else 
 
                    End Select 
                End If 
            End If 
 
        End Sub 
 

The MainViewModel has an ICommand instance called ShowDiagnosticviewCommand. This Command is bound to the RadMenuItem in my MainView as follows:
<!-- ... --> 
<telerik:RadMenuItem Header="Tools"
     <telerik:RadMenuItem Header="Diagnostics" Command="{Binding Path=ShowDiagnosticsViewCommand}" /> 
</telerik:RadMenuItem> 
<!-- ... ---> 
 

The MainViewModel has the following code:
       /// <summary> 
        /// Returns a command that opens the image view. 
        /// </summary> 
        public ICommand ShowDiagnosticsViewCommand 
        { 
            get 
            { 
                if (_showDiagnosticsViewCommand == null
                { 
                    _showDiagnosticsViewCommand = new RelayCommand((param) => this.ShowDiagnosticsView(), (param) => !this.DiagnosticsViewActive); 
                } 
                return _showDiagnosticsViewCommand; 
            } 
        } 
 
        private void ShowDiagnosticsView() 
        { 
            Messenger.Default.Send<CommandMessage>(new CommandMessage(this, Messages.ViewMessages.ShowDiagnosticsView.ToString())); 
 
        } 
 

Here is the call stack when i break on the Window_Deactivated event of the window being launched:

Call stack:
 
Imager.exe!CM.Imager.DiagnosticsView.Window_Deactivated(Object sender = {CM.Imager.DiagnosticsView}, System.EventArgs e = {System.EventArgs}) Line 57   Basic 
    [External Code]  
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadMenuItem.OnIsSubmenuOpenChanged(System.Windows.DependencyObject d = {Telerik.Windows.Controls.RadMenuItem Header:Tools Items.Count:7}, System.Windows.DependencyPropertyChangedEventArgs e = {System.Windows.DependencyPropertyChangedEventArgs}) Line 1813 + 0xa bytes C# 
    [External Code]  
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadMenuItem.IsSubmenuOpen.set(bool value = false) Line 496 C# 
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadMenuItem.CloseMenu() Line 944   C# 
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadMenuItem.OnIsSelectedChanged(System.Windows.DependencyObject d = {Telerik.Windows.Controls.RadMenuItem Header:Tools Items.Count:7}, System.Windows.DependencyPropertyChangedEventArgs e = {System.Windows.DependencyPropertyChangedEventArgs}) Line 1756    C# 
    [External Code]  
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadMenuItem.IsSelected.set(bool value = false) Line 648    C# 
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.MenuBase.CurrentSelection.set(Telerik.Windows.Controls.RadMenuItem value = null) Line 302  C# 
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.MenuBase.CloseAll() Line 327   C# 
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadMenuItem.OnClickImpl() Line 1126    C# 
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadMenuItem.OnClick() Line 1488    C# 
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadMenuItem.ClickItem() Line 2527  C# 
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadMenuItem.HandleMouseUp() Line 1098  C# 
    Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadMenuItem.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e = {System.Windows.Input.MouseButtonEventArgs}) Line 1291   C# 
    [External Code]  
 

My guess is that somehow the window is losing focus back to the RadmenuItem after the bound command is fired, possibly on the RadmenuItem.OnIsSubmenuOpenChanged().

For now, I have switched back to using the default WPF menu. I prefer the Radmenu because of the nice theme support. Any help with this problem will be appreciated.

Thanks
Chris Boarman



Hristo
Telerik team
 answered on 08 Jul 2010
5 answers
215 views
Hi.

When you add a comment to a cell in MS Excel, you get a red triangle in the right top corner of the cell.
I would like to do the same on my grid. I have added the tooltip to the cell, but I would like the indicator that there is a comment on the cell.

Any ideas?
Pavel Pavlov
Telerik team
 answered on 08 Jul 2010
4 answers
160 views
Just wanted to let you know that placing RadRibbonBar from Q2 beta build into WPF window, adding two rad buttons into application menu and adding one tab not working - running application throws Object null reference exception.

Regards,
Saulius
Valentin.Stoychev
Telerik team
 answered on 08 Jul 2010
1 answer
111 views
How to call a function on each item of the selecteditems in DataGridView

P.S. NVM got it working
Vlad
Telerik team
 answered on 08 Jul 2010
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?