This is a migrated thread and some comments may be shown as answers.

RadGridView doesn't display at all

4 Answers 321 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tarun
Top achievements
Rank 1
Tarun asked on 14 Aug 2012, 05:12 AM
Sorry for the naive question...

I am a first time user of the telerik WPF controls, I am following the tutorial here to add a RadGridView to my application...

My wpf application is build using MVVM, I am adding the RadGridView control to one of the views, see implementation below...

<UserControl x:Class="SprintAnalyzer.Module.Presentation.Views.MiddleView"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
            xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Interactivity.InteractionRequest;assembly=Microsoft.Practices.Prism.Interactivity"
            xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:interactions="clr-namespace:SprintAnalyzer.Module.Presentation.Interactions"
             xmlns:Views="clr-namespace:SprintAnalyzer.Module.Presentation.Views" mc:Ignorable="d"            
             d:DesignHeight="300" d:DesignWidth="300">
 
    <Grid x:Name="LayoutRoot" Background="Lavender">
        <telerik:RadGridView x:Name="radGridView" AutoGenerateColumns="True"
                             ItemsSource="{Binding Path=AnalysisResults}" >
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Result}" Header="Result"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Category}" Header="Category"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</UserControl>

Note - I have added a reference to xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" my project already has a reference to the Telerik.Windows.Code, Telerik.Windows.Controls.GridView and Telerik.Windows.Controls.Input. 

When I run the application, the grid is not displayed at all. 

The viewmodel implementation,

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Events;
using SprintAnalyzer.Common;
using SprintAnalyzer.Common.Service;
using SprintAnalyzer.Module.Presentation.Models;
using SprintAnalyzer.Module.Presentation.Requests;
using SprintAnalyzer.RulesEngine;
using SprintAnalyzer.Common.Events;
 
namespace SprintAnalyzer.Module.Presentation.ViewModels
{
    public class MiddleViewModel : ViewModelBase
    {
        private readonly IEventAggregator _eventAggregator;
        private ICommand _button;     
        public string Output { get; private set; }
 
        public ICommand OnClick
        {
            get { return _button; }
            set
            {
                _button = value;
                RaisePropertyChangedEvent("OnClick");
            }
        }
 
        public MiddleViewModel(IApplicationContextService contextService, IEventAggregator eventAggregator)
        {
            this._contextService = contextService;
            this._eventAggregator = eventAggregator;
            this.OnClick = new DelegateCommand(this.Button_Clicked);
            _eventAggregator.GetEvent<AnalysisRunTrigger>().Subscribe(ExecuteAnalysisRunTrigger, ThreadOption.BackgroundThread);
            _eventAggregator.GetEvent<AnalysisResultEvent>().Subscribe(OnAnalysisRunResult, ThreadOption.UIThread);
            _eventAggregator.GetEvent<ExceptionRaisedEvent>().Subscribe(OnExceptionRaised,
                                                                       ThreadOption.UIThread);
            this.AnalysisResults = new ObservableCollection<AnalysisResult>();
        }
 
        private void OnExceptionRaised(ExceptionDetail obj)
        {
               // Removed for now
        }
 
        private void OnAnalysisRunResult(AnalysisResult analysisResult)
        {
            AnalysisResults.Add(analysisResult);
        }
 
        private static Person CreatePerson()
        {
               // Removed for now
        }
 
        private void SetPeopleExecute()
        {
                // Removed for now
        }
 
        private void GetPersonCallback(Person p)
        {
              // Removed for now
        }
 
        private void CancelCallback()
        {
             // Removed for now
        }
 
        private ObservableCollection<AnalysisResult> _analysisResults;
        public ObservableCollection<AnalysisResult> AnalysisResults
        {
            get
            {
                return _analysisResults;
            }
            set
            {
                _analysisResults = value;
                RaisePropertyChangedEvent("AnalysisResults");
            }
        }
 
        private void ExecuteAnalysisRunTrigger(string triggerState)
        {
            try
            {
                switch (triggerState)
                {
                    case "StartAnalyzis":
                        
                        rulesFactory.Execute();
 
                        break;
                }
            }
            catch (Exception ex)
            {
                _eventAggregator.GetEvent<ExceptionRaisedEvent>().Publish(new ExceptionDetail() { Message = ex.Message });
            }
        }
 
        private string _message;
        private readonly IApplicationContextService _contextService;
 
        public string Message
        {
            get { return _message; }
            set
            {
                _message = value;
                RaisePropertyChangedEvent("Message");
            }
        }
 
        private void Button_Clicked()
        {
            //throw new NotImplementedException();
        }
    }
}


Note that the AnalysisResults is ObservableCollection...

If I take the RadGridView out of the equation and use the good old Wpf GridView control, my application works, I can see the grid load up with the values for the same code...

What am I missing?
 
 

4 Answers, 1 is accepted

Sort by
0
Tarun
Top achievements
Rank 1
answered on 14 Aug 2012, 02:12 PM
Bump...

Any one?
0
Dimitrina
Telerik team
answered on 14 Aug 2012, 02:28 PM
Hi,

In order to use the RadGridView please add references to the following assemblies:

Telerik.Windows.Controls
Telerik.Windows.Controls.GridView
Telerik.Windows.Controls.Input
Telerik.Windows.Data
 

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Doug
Top achievements
Rank 2
answered on 25 Jun 2014, 07:25 PM
I have the same issue even with your sample alone.  The XAML has an outline for the grid, but doesn't display anything.  When you run the program you get a blank white screen.  Only caveat is I am using the Office 2013 theme.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
using Telerik.Windows.Controls.Input;
using Telerik.Windows.Data;

namespace TelerikWpfApp1
{
    /// <summary>
    /// Interaction logic for GridTest.xaml
    /// </summary>
    public partial class GridTest : Window
    {
        public GridTest()
        {
            InitializeComponent();
        }

        public class DemoClass
        {
            public int ID { get; set; }
            public string Name { get; set; }
            public string Company { get; set; }
            public bool IsComplete { get; set; }
            public DateTime DueDate { get; set; }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ObservableCollection<DemoClass> myDemoClasses = new ObservableCollection<DemoClass>();

            for (int x = 1; x <= 2000; x++)
            {
                var dc = new DemoClass();
                dc.ID = x;
                dc.Name = "Person " + x.ToString();
                dc.Company = x % 2 == 0 ?
                    "Super Company " + x.ToString() : "Sub-par company " + x.ToString();
                dc.IsComplete = x % 4 == 0 ? true : false;
                dc.DueDate = DateTime.Today.AddDays(x);
                myDemoClasses.Add(dc);
            }

            radGridView1.ItemsSource = myDemoClasses;

        }
    }
}


XAML

<Window x:Class="TelerikWpfApp1.GridTest"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        Title="GridTest" Height="300" Width="300" Loaded="Window_Loaded">
    <Grid>
        <telerik:RadGridView HorizontalAlignment="Left" Margin="77,46,0,0" Name="radGridView1" VerticalAlignment="Top" />
    </Grid>
</Window>


0
Dimitrina
Telerik team
answered on 27 Jun 2014, 08:45 AM
Hi,

It seems you have referenced the NoXaml binaries. In that case you need to merge the respective Resource Dictionaries.
You can find more information on Implicit Styles here.


Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Tarun
Top achievements
Rank 1
Answers by
Tarun
Top achievements
Rank 1
Dimitrina
Telerik team
Doug
Top achievements
Rank 2
Share this question
or