Telerik Forums
UI for WPF Forum
8 answers
127 views
I have created RadGridview to check the Validating Data on a Property Level. When i run the code and give invalid value, exception is thrown but it wouldn't been caught by the RadGridView. I am Using
WPF 4.0    Version 2010.2 924

Here is the Code

<Window x:Class="WpfApplication1.Window1"
        Title="Window1" Height="300" Width="565" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Loaded="Window_Loaded">
    <Grid>
        <telerik:RadGridView Name="radGridView1" AddingNewDataItem="radGridView1_AddingNewDataItem" ShowInsertRow="True">
        </telerik:RadGridView>
    </Grid>
</Window>

using System;
using System.Windows;
using System.Collections.ObjectModel;
 
namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
 
        public ObservableCollection<Employee> GetEmployees()
        {
            ObservableCollection<Employee> employees = new ObservableCollection<Employee>();
            return employees;
        }
 
        private void radGridView1_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
        {
            e.NewObject = new Employee();
        }
 
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.radGridView1.ItemsSource = this.GetEmployees();
        }
 
    }
 
    public class Employee
    {
        string _FirstName;
 
        public string FirstName
        {
            get { return _FirstName; }
            set
            {
                if (value.Length > 5)
                {
                    throw new Exception("Firstname must be less than 6");
                }
                 _FirstName = value;
            }
        }
         
     }
}

check the attachment for error screen shot.
Rajesh
Top achievements
Rank 1
 answered on 05 Jun 2012
3 answers
130 views
I there any code snippet (or already existing control) on how to make an option dialog like the one of Microsoft Word 2007.

I would like to use Telerik controls so that I can take advantage of the themes.

I'm using PRISM and my goal is to make a "options service" component in which different modules can push options view.

Regards,

Nicolas
Nicolas
Top achievements
Rank 1
 answered on 05 Jun 2012
7 answers
356 views
Hi,

I've implemented this helpful example code (http://demos.telerik.com/silverlight/#GridView/PrintAndExportWithRadDocument) and it is all working as expected, however the table that is created does not take up the whole width of the page. I notice it uses the column widths of the RadGridView, however they are not ideal in the A4 pdf. I would like the table that is created for the pdf to size itself based on content. Is this possible, and if so, how would I do it? I figure it's got something to do with this line:
cell.PreferredWidth = new TableWidthUnit((float)columns[i].ActualWidth);


Thanks
Iva Toteva
Telerik team
 answered on 05 Jun 2012
1 answer
139 views
I'm working on a project where I have a large amount of data stored in a database organized into a tree. I'm using the EntityFramework, so I'm using the QueryableEntityCollectionView to filter my data and a RadTreeView to display it.

However, I also need support for drag & drop to add/move/delete items. By default, the RadTreeView won't let me drop into this tree as it is. If it was an IList or an ObservableCollection, it will let me, but I need to be able to refresh/filter the visible nodes in the tree.

Is there a way to override the d&d support in RadTreeView to allow drops, and run custom code on drop complete?

I did see this post (http://www.telerik.com/community/forums/silverlight/treeview/use-drag-and-drop-to-rearrange-items-and-then-persist-order-back-to-database.aspx) but it's for silverlight and I don't think the WCF side is needed for a WPF + EF application.

Any advice?
Thanks!
Hristo
Telerik team
 answered on 05 Jun 2012
0 answers
124 views
When the list box lives inside a RadTileView, the OnDrop event will get fired twice with the same parameters.
<telerik:RadTileView>
    <telerik:RadTileViewItem>
 
        <Grid x:Name="LayoutRoot" Background="White">
            <Grid.Resources>
                <Style TargetType="ListViewItem">
                    <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True"></Setter>
                </Style>
                <DataTemplate x:Key="ApplicationTemplate">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Margin="5" Text="{Binding Name}" VerticalAlignment="Center"></TextBlock>
                    </StackPanel>
                </DataTemplate>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <ListView x:Name="ApplicationList" ItemTemplate="{StaticResource ApplicationTemplate}" AllowDrop="True"/>
            <ListView x:Name="MyAppList" Background="Gray" Grid.Column="1" 
            ItemTemplate="{StaticResource ApplicationTemplate}" AllowDrop="True"/>
        </Grid>
    </telerik:RadTileViewItem>
</telerik:RadTileView>


public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        ObservableCollection<Item> items = new ObservableCollection<Item>();
        for (int i = 1; i <= 10; i++)
            items.Add(new Item() { Name = string.Format("item {0}", i) });
        ApplicationList.ItemsSource = items;
        MyAppList.ItemsSource = new ObservableCollection<Item>();
 
        DragDropManager.AddDragInitializeHandler(ApplicationList, OnDragInitialize);
        DragDropManager.AddDragInitializeHandler(MyAppList, OnDragInitialize);
        DragDropManager.AddGiveFeedbackHandler(ApplicationList, OnGiveFeedback);
        DragDropManager.AddGiveFeedbackHandler(MyAppList, OnGiveFeedback);
        DragDropManager.AddDragDropCompletedHandler(ApplicationList, OnDragCompleted);
        DragDropManager.AddDragDropCompletedHandler(MyAppList, OnDragCompleted);
        DragDropManager.AddDropHandler(ApplicationList, OnDrop);
        DragDropManager.AddDropHandler(MyAppList, OnDrop);
    }
 
    private void OnDragInitialize(object sender, DragInitializeEventArgs args)
    {
        args.AllowedEffects = DragDropEffects.Move;
        //args.AllowedEffects = DragDropEffects.All;
        args.Data = ((FrameworkElement)args.OriginalSource).DataContext;
        args.DragVisual = new ContentControl { Content = args.Data, ContentTemplate = LayoutRoot.Resources["ApplicationTemplate"] as DataTemplate };
    }
 
    private void OnGiveFeedback(object sender, Telerik.Windows.DragDrop.GiveFeedbackEventArgs args)
    {
        System.Diagnostics.Trace.WriteLine(string.Format("{0} - OnGiveFeedback sender={1}", DateTime.Now, sender));
        args.SetCursor(Cursors.Arrow);
        args.Handled = true;
    }
 
    private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs args)
    {
        System.Diagnostics.Trace.WriteLine(string.Format("{0} - OnDrop sender={1}", DateTime.Now, sender));
        ((IList)(sender as ListBox).ItemsSource).Add(((DataObject)args.Data).GetData(typeof(Item)));
    }
 
    public void OnDragCompleted(object sender, Telerik.Windows.DragDrop.DragDropCompletedEventArgs args)
    {
        System.Diagnostics.Trace.WriteLine(string.Format("{0} - OnDragCompleted sender={1}", DateTime.Now, sender));
        ((IList)(sender as ListBox).ItemsSource).Remove(args.Data);
    }
}
 
public class Item
{
    public string Name { get; set; }
}

Wenrong
Top achievements
Rank 1
 asked on 05 Jun 2012
0 answers
77 views
I have implemented a basic drag-n-drop using Telerik's new DragDropManager, pretty much the same as instructed here http://www.telerik.com/help/wpf/dragdropmanager-getting-started.html except that I am using ListView instead of ListBox.

Although it works, but I need help on the following two things:
  1. How to I limit the drag-n-drop so that it can only happen between the two listviews? i.e. disallow dropping to the same listview as the drag source.
  2. How to change cursor based on the above criteria? I try to monitor OnGiveFeedback(), but the sender is always the drag source...
Wenrong
Top achievements
Rank 1
 asked on 05 Jun 2012
0 answers
89 views
Hi guys,
basically I have a class derived from GridViewGroupFooterCell, and I need to replace GridViewGroupFooterCell with the derived one in the GridView. Do you guys have any idea how I can archive this?

Thanks in advance.

-Henry
heng
Top achievements
Rank 1
 asked on 05 Jun 2012
3 answers
82 views
Is it possible to 'freeze' the groupheader row?
This way the current group would always be visible while (vertically) scrolling the data in the gridview.
Vlad
Telerik team
 answered on 05 Jun 2012
1 answer
168 views

Hi,

 

I have a requirement

 

Requirement 1# : Inside a Hirerchy Template placed 2 Grids where in

1st grid 3 columns where 1 column has Combo Box loaded with Values.

 

For ex: Football, Disco

 

If i select Football, 2 grid placed inside Hirechy Template should be visible or else visbility of that grid should be collapsed.

How can i solve this.

 

Requirement 2#: Can i pass Observable collection as converter parameter

 

<Radcombobox selecteditem={Binding collection, converter={}} -> to show as like A,B,C (Selected Items as comma separated)

 

<controls:RadGridView Name="clubsGrid" 
                      ItemsSource="{Binding Clubs}" Grid.Row="0" 
                  AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" DataContext="{StaticResource MyViewModel}">
            <controls:RadGridView.ChildTableDefinitions>
                <controls:GridViewTableDefinition/>
            </controls:RadGridView.ChildTableDefinitions>
            <controls:RadGridView.Columns>
                <controls:GridViewDataColumn DataMemberBinding="{Binding Name}"
                                            Header="Est."></controls:GridViewDataColumn>
                <controls:GridViewDataColumn DataMemberBinding="{Binding Established}"></controls:GridViewDataColumn>
            </controls:RadGridView.Columns>
            <controls:RadGridView.HierarchyChildTemplate>
                <DataTemplate                      
                                            <controls:RadGridView Name="playersGrid" 
                                     ItemsSource="{Binding Players}" 
                                     AutoGenerateColumns="False" EnableRowVirtualization="False" EnableColumnVirtualization="False"
                                        <controls:RadGridView.ChildTableDefinitions>
                <controls:GridViewTableDefinition/>
            </controls:RadGridView.ChildTableDefinitions>

                            <controls:RadGridView.Columns>
                                <controls:GridViewDataColumn DataMemberBinding="{Binding Name}">                                    
                                </controls:GridViewDataColumn>
                                <controls:GridViewDataColumn DataMemberBinding="{Binding SelectedItem.Name}">
                                    <controls:GridViewDataColumn.CellEditTemplate>
                                        <DataTemplate>
                                            <RadControls:RadComboBox ItemsSource="{Binding Hobbies, Mode=OneTime}" SelectedItem="{Binding SelectedItem,Mode=TwoWay}" SelectedValue="Name" DisplayMemberPath="Name" >                                                
                                            </RadControls:RadComboBox>                                            
                                        </DataTemplate>
                                    </controls:GridViewDataColumn.CellEditTemplate>
                                </controls:GridViewDataColumn>                         
                            </controls:RadGridView.Columns
                                    

<

 

 

telerik:RadGridView.HierarchyChildTemplate>

 

 

 

 

<HierarchicalDataTemplate>

 


                                    <controls:RadGridView Name="Hobbies" 
                                     ItemsSource="{Binding Hobbies}" 
                                     AutoGenerateColumns="True" EnableRowVirtualization="False" EnableColumnVirtualization="False"/>

            
                        </controls:RadGridView>

</

 

 

HierarchicalDataTemplate>

 

 

 

 

</telerik:RadGridView.HierarchyChildTemplate>

 


                                                                </DataTemplate>
            </controls:RadGridView.HierarchyChildTemplate>
        </controls:RadGridView>
Prakash
Top achievements
Rank 1
 answered on 05 Jun 2012
1 answer
76 views
I,

in my project I use Telerik V2010.3.1314.35 and with my RadGridView, when I click on the filter icon in a column header, sometime the filter dialog appear behind the grid ?!?

Thank's
Vlad
Telerik team
 answered on 05 Jun 2012
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?