Telerik Forums
UI for WPF Forum
0 answers
148 views
Hi,

I'm developing a library based on Microsoft's UI Automation Framework which allows creating automated tests involving the GridView control.

One of the main features of this library relating to this control is, of course, the ability to fetch all rows currently displayed in the grid. I do this by accessing the GridView's AutomationElement object in the UI tree, and then fetch all descendants that are of the GridViewRow class.

The problem is that the GridView in question is virtualized, hence the code described above only fetches a small part of the grid's content (the one that's currently visible).

Microsoft's suggestion of dealing with this problem is using the ItemContainer pattern, that exposes a method that allows to find all elements given a certain condition, regardless of whether or not they're virtualized, and then use the VirtualizedItem pattern's Realize() method in order to bring the item into view.

The problem I have with this is twofold: one, I couldn't find any AutomationElement that supports the ItemContainer pattern (not the GridView itself, and none of the custom elements under it). Two, even if I did, in order to construct a condition for the ItemContainer to work on, I need each row to have a unique identifier, and this is not the case. Even the RuntimeId property which is supposed to be unique gets recycled as you scroll down.

I can solve this problem by scrolling through the grid and fetching all unique elements, but clearly this is not the best solution, especially given the VirtualizedItem pattern intended exactly for this purpose.

I would love to hear the experts on this!

Tal
Tal
Top achievements
Rank 1
 asked on 11 Jun 2013
1 answer
80 views
Hi,

I'm using the Telerik's Docking control to create an advance UI, but I'm having some problems to achieve a neccesary behaviour with the RadPanes.

I have a main RadDocking control that contains three main RadPanes in one RadPaneGroup. Also, each of these three RadPanes contains another two RadPane, but... I want to these new two RadPanes move and dock in the context of the parent RadPane only.

Example:
- RadDocking
  -- RadPane main1
    -- RadPane child1
    -- RadPane child2
  -- RadPane main2
  -- RadPane main3

RadPane main1, RadPane main2 and RadPane main3 can move, dock and change the positions between them as usual.
RadPane child1 and RadPane child2 can move, dock and change the positions between them, but cannot move in a context out of RadPane main1. Also, if you move RadPane main1, the RadPane child1 and RadPane child2 will be move with RadPane main1 as like as a usual content.

Currently, all RadPanes (main and childs) can move and dock to any place in the windows. I do not want this.

I thought that creating a new RadDocking into RadPane main1 will solve this, but RadDockings in RadDocking is not allowed.


On the other hand, I know that in WinForms using ToolTabStrip this behaviour is possible, but I do not know how to do in WPF.
Vladi
Telerik team
 answered on 11 Jun 2013
1 answer
109 views
Hi Telerik,

I'm glad to see you're including a point series in your next release. At the moment I'm simulating a point series by styling a LineSeries, and making the stroke transparent. I then use a PointTemplate to make the point, as below.

My question is how can I bind the fill brush of the ellipse I'm using to the palette colour for the series?

thanks

 <Style x:Key="LineSeriesAsPointsStyle" TargetType="{x:Type telerik:LineSeries}">
    <Setter Property="StrokeShapeStyle">
    <Setter.Value>
    <Style TargetType="{x:Type Path}">
    <Setter Property="Stroke" Value="#00000000"/>
    <Setter Property="StrokeThickness" Value="0"/>
    </Style>
    </Setter.Value>
    </Setter>
<Setter Property="PointTemplate">
<Setter.Value>
<DataTemplate>
<Ellipse Height="7" Width="7" Fill="Red" /><!-- here is the problem -->
</DataTemplate>
</Setter.Value>
</Setter>
    </Style>
Petar Kirov
Telerik team
 answered on 11 Jun 2013
3 answers
306 views

Is there any way to plot negative values in Pie chart like we can do in Microsoft Excel.

Below are snap shots of two charts having negative values one plotted using telerik chart and another using Excel.

Evgenia
Telerik team
 answered on 11 Jun 2013
2 answers
93 views
Great work on the ChartView. I'm getting to know the control with a view to hopefully using it in a significant project. As a long time WPF and MVVM developer, I'm happy to say that so far it works in the way I expect it to work. 

One thing that I'm finding strange though, is the order of categories on a vertical categorical axis. Let's say I have four categories in my data,  'North', 'East', 'South', 'West', in that order. In a horizontal bar chart I would expect 'North' to be the top bar and 'West' to be the bottom. Your implementation has it the other way round.

Now, I can see why you do it like this, as other axes (linear, logarithmic) increase in value as they move away from the origin. Excel does the same too, but allows a switch for people who prefer their axes the other way round.

Is there an easy way to switch them, or shall I just sort them myself? 

thanks
Pete
Peter Chapman
Top achievements
Rank 1
 answered on 11 Jun 2013
1 answer
164 views
Hi Telerik Team,

    I need suggestion on moving items from listbox to tileview, in which tileview's drag mode is swap and tileview will contain rows and columns of empty placeholder for example like <div>,when items form listbox dragged and droped on this empty placeholder, this empty placeholder gets replaced with dropped item, and within tileview items interchange in swap mode.

Regards,
Vivek Dev
Pavel R. Pavlov
Telerik team
 answered on 11 Jun 2013
5 answers
112 views
I have a grid with 49 columns. Column 1 is the day of the week, and the rest of the columns are the time of day in 30 minute increments. What I'm trying to accomplish is when I click and drag across several cells, I want to change the back color of any cell I drag over. What is the best way to accomplish this with the radGridView?
Maya
Telerik team
 answered on 11 Jun 2013
3 answers
152 views
Hi,

I have the problem with textbox in RadListBox. There's empty RadListBox ( no resources, no styles etc. ) and TextBox inside. When i type any character in textbox it is working properly, but when i type spacebar, i have double space. It's everytime i type spacebar and only spacebar. For example when i type abc spacebar bca in my textbox i have abc  bca, with 2 white spaces. every one spacebar gives mi two white spaces
Vladi
Telerik team
 answered on 10 Jun 2013
1 answer
202 views
I'm trying to drag items from a TreeGridView to a RadGridView, such that a single item will be stored in a single cell.

I have predefined columns with headers "A" to "Z" and want to drop items from the treeview to a single column, i.e. drop an item to column A and another item to column H, such that the rest of the columns are empty.

All of this should happen on a single row under the headers. I also don't want to be able to drag the column headers.

Are there any good solutions to this problem? I'm not sure what to do. Maybe there is a better View to use?
This is what I have so far:

Example.xaml.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.DragDrop;
using Telerik.Windows.Controls.TreeView;
using System.Windows.Controls;
using System.Windows.Data;
 
namespace Telerik.Windows.Examples.DragAndDrop.WPF.TreeToGrid
{
    public partial class Example : System.Windows.Controls.UserControl
    {
        MyCollection results = new MyCollection();
        public Example()
        {
 
            InitializeComponent();
 
            // Set the items source of the controls:
            allProductsView.ItemsSource = CategoryViewModel.Generate();
 
            //IList orderSource = new ObservableCollection<string>();
            //orderView.ItemsSource = orderSource;
 
            //foreach (ProductViewModel product in ProductViewModel.Generate(6))
            //{
            //    wishlistSource.Add(product);
            //}
 
            // Allow dropping into the ListBox and GridView only if the
            // dragged items are all products:
            RadDragAndDropManager.AddDropQueryHandler(orderView, OnDropQuery);
 
            // Change the drag cue and choose an action for the sucessful drop
            // in the Order GridView:
            RadDragAndDropManager.AddDropInfoHandler(orderView, OnGridViewDropInfo);
 
            // Allow dragging of the Wishlist and Order items:
            RadDragAndDropManager.AddDragQueryHandler(orderView, OnOrderDragQuery);
 
            // Handle the case when items are dragged away from  the ListBox
            // and the Order:
            RadDragAndDropManager.AddDragInfoHandler(orderView, OnOrderDragInfo);
 
            List<String> details = new List<string>();
            char a = 'A';
            char z = 'Z';
 
            for (char cntr = a; cntr <= z; cntr++)
            {
 
                details.Add(cntr + "");
            }
 
 
            results.Add(details);
 
 
 
            AddColumns(details);
 
 
 
            //-----set binding here or in Xaml------------------------
 
            Binding binding = new Binding();
 
            binding.Source = results;
 
            orderView.SetBinding(RadGridView.ItemsSourceProperty, binding);
 
 
        }
        private void AddColumns(List<String> myColumns)
 
        {
            //RadGridView viewLayout = new RadGridView();
            //GridView viewLayout = new GridView();
 
 
            for (int i = 0; i < myColumns.Count; i++)
 
            {
                orderView.Columns.Add(new Telerik.Windows.Controls.GridViewColumn
 
                {
 
                    Header = myColumns[i],
                    IsResizable = false,
                     
                    //BindingGroup = new BindingGroup(),
                    //DisplayMemberBinding = new Binding(" ")
 
                });
 
            }
            orderView.CanUserInsertRows = false;
 
 
        }
 
        private void OnOrderDragInfo(object sender, DragDropEventArgs e)
        {
            IEnumerable draggedItems = e.Options.Payload as IEnumerable;
 
            if (e.Options.Status == DragStatus.DragInProgress)
            {
                //Set up a drag cue:
                TreeViewDragCue cue = new TreeViewDragCue();
                //Here we need to choose a template for the items:
                cue.ItemTemplate = this.Resources["ProductTemplate"] as DataTemplate;
                cue.ItemsSource = draggedItems;
                e.Options.DragCue = cue;
            }
            else if (e.Options.Status == DragStatus.DragComplete)
            {
                IList source = this.orderView.ItemsSource as IList;
                foreach (object draggedItem in draggedItems)
                {
                    source.Remove(draggedItem);
                }
            }
        }
 
        private void OnOrderDragQuery(object sender, DragDropQueryEventArgs e)
        {
            if (this.orderView != null)
            {
                IList selectedItems = this.orderView.SelectedItems;
                e.QueryResult = selectedItems.Count > 0;
                e.Options.Payload = selectedItems;
            }
 
            e.QueryResult = true;
            e.Handled = true;
        }
 
        private void OnGridViewDropInfo(object sender, DragDropEventArgs e)
        {
            ICollection draggedItems = e.Options.Payload as ICollection;
 
            // Get the drag cu that the TreeView or we have created
            TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue;
 
            if (e.Options.Status == DragStatus.DropPossible)
            {
                // Set a suitable text:
                cue.DragActionContent = String.Format("Add {0} item{1} to Order", draggedItems.Count, draggedItems.Count > 1 ? "s" : String.Empty);
                cue.IsDropPossible = true;
                this.orderView.Background = this.Resources["DropPossibleBackground"] as Brush;
            }
            else if (e.Options.Status == DragStatus.DropImpossible)
            {
                cue.DragActionContent = null;
                cue.IsDropPossible = false;
            }
            else if (e.Options.Status == DragStatus.DropComplete)
            {
                IList items = this.orderView.ItemsSource as IList;
                foreach (object draggedItem in draggedItems)
                {
                    items.Add(draggedItem);
                }
            }
 
            if (e.Options.Status != DragStatus.DropPossible)
            {
                this.orderView.Background = new SolidColorBrush(Colors.White);
            }
        }
 
        private void OnDropQuery(object sender, DragDropQueryEventArgs e)
        {
            // We allow drop only if the dragged items are products:
            ICollection draggedItems = e.Options.Payload as ICollection;
            bool result = draggedItems.Cast<object>().All((object item) => item is ProductViewModel);
            e.QueryResult = result;
            e.Handled = true;
 
            // Note that here we agree to accept a drop. We will be notified
            // in the DropInfo event whether a drop is actually possible.
        }
    }
 
    public class ExampleTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is ProductViewModel)
            {
                return ProductTemplate;
            }
            else if (item is CategoryViewModel)
            {
                return CategoryTemplate;
            }
            return null;
        }
 
        public DataTemplate ProductTemplate { get; set; }
        public DataTemplate CategoryTemplate { get; set; }
    }
 
    public class CategoryViewModel
    {
        public static IList Generate()
        {
            var apiOutput1 = new CategoryViewModel();
            apiOutput1.Title = "List items";
            apiOutput1.Items.Add("Item1");
            apiOutput1.Items.Add("Item2");
 
            var apiOutput2 = new CategoryViewModel();
            apiOutput2.Title = "Item Price";
            apiOutput2.Items.Add("Price1");
            apiOutput2.Items.Add("Price2");
 
            var userDefFields = new CategoryViewModel();
            userDefFields.Title = "User fields";
            userDefFields.Items.Add("Field1");
            userDefFields.Items.Add("Field2");
 
 
 
            IList result = new List<object>();
 
            result.Add(apiOutput1);
            result.Add(apiOutput2);
            result.Add(userDefFields);
 
            return result;
        }
 
        public CategoryViewModel()
        {
            Items = new ObservableCollection<object>();
        }
 
        public string Title { get; set; }
        public IList Items { get; set; }
    }
 
    public class ProductViewModel
    {
        public ProductViewModel(string name, string desc)
        {
            Name = name;
            Description = desc;
        }
        public string Name { get; set; }
        public string Description { get; set; }
 
        public override string ToString()
        {
            return Name.ToString();
        }
    }
    public class MyCollection : ObservableCollection<List<string>>
 
    {
 
        public MyCollection()
 
            : base()
 
        {
 
        }
 
    }
}

Example.xaml
<UserControl x:Class="Telerik.Windows.Examples.DragAndDrop.WPF.TreeToGrid.Example"
        xmlns:nav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
        xmlns:gridViewElements="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
        xmlns:example="clr-namespace:Telerik.Windows.Examples.DragAndDrop.WPF.TreeToGrid"
        xmlns:dragDrop="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls">
    <UserControl.Resources>
        <telerik:MetroColors x:Key="MetroColors" />
        <SolidColorBrush x:Key="AccentBrush" Color="{Binding Source={StaticResource MetroColors}, Path=Palette.AccentColor}" />
        <SolidColorBrush x:Key="BasicBrush" Color="{Binding Source={StaticResource MetroColors}, Path=Palette.BasicColor}" />
        <SolidColorBrush x:Key="StrongBrush" Color="{Binding Source={StaticResource MetroColors}, Path=Palette.StrongColor}" />
        <SolidColorBrush x:Key="MainBrush" Color="{Binding Source={StaticResource MetroColors}, Path=Palette.MainColor}" />
        <SolidColorBrush x:Key="MarkerBrush" Color="{Binding Source={StaticResource MetroColors}, Path=Palette.MarkerColor}" />
        <SolidColorBrush x:Key="ValidationBrush" Color="{Binding Source={StaticResource MetroColors}, Path=Palette.ValidationColor}" />
 
        <DataTemplate x:Key="WishlistProduct">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}" FontWeight="Bold" />
                <TextBlock Text=", (" Foreground="Gray" />
                <TextBlock Text="{Binding UnitPrice}" Foreground="Gray" />
                <TextBlock Text=")" Foreground="Gray" />
            </StackPanel>
        </DataTemplate>
 
        <HierarchicalDataTemplate x:Key="CategoryTemplate" ItemsSource="{Binding Items}">
            <StackPanel Orientation="Horizontal">
                <Image Width="16" Height="16" Source="../../Images/DragAndDrop/folder_icon.png" Margin="3"
                        VerticalAlignment="Center" />
                <TextBlock Text="{Binding Title}" Foreground="{StaticResource MainBrush}" Margin="2" VerticalAlignment="Center" />
            </StackPanel>
        </HierarchicalDataTemplate>
 
        <DataTemplate x:Key="ProductTemplate">
            <DockPanel Margin="2" MaxWidth="200">
                <TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="{StaticResource MainBrush}" DockPanel.Dock="Top" />
                <!--<TextBlock Text="{Binding Description}" DockPanel.Dock="Left"
                        Margin="2 0 0 0" Foreground="{StaticResource MainBrush}" TextWrapping="Wrap" /> -->
            </DockPanel>
        </DataTemplate>
 
        <example:ExampleTemplateSelector x:Key="ExampleTemplateSelector"
                CategoryTemplate="{StaticResource CategoryTemplate}"
                ProductTemplate="{StaticResource ProductTemplate}" />
 
        <Style TargetType="nav:RadTreeViewItem" x:Key="TreeViewItemStyle">
            <Setter Property="IsExpanded" Value="True" />
        </Style>
 
        <!--Note: With this style we make the ListBoxItems draggable:-->
        <Style TargetType="gridViewElements:GridViewRow" x:Key="OrderItemStyle">
            <Setter Property="dragDrop:RadDragAndDropManager.AllowDrag" Value="True" />
        </Style>
 
     
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="3*" />
        </Grid.ColumnDefinitions>
 
        <!--All Products-->
        <Border BorderBrush="#C8C9CC" BorderThickness="2" CornerRadius="6" Margin="46 46 0 46" Background="White">
            <DockPanel>
                <Border DockPanel.Dock="Top" Background="{StaticResource AccentBrush}" CornerRadius="4 4 0 0">
                    <TextBlock Text="All Products" Margin="20 5 5 5" Foreground="{StaticResource MainBrush}" FontSize="14"/>
                </Border>
                <nav:RadTreeView x:Name="allProductsView"
                        ItemTemplateSelector="{StaticResource ExampleTemplateSelector}"
                        ItemContainerStyle="{StaticResource TreeViewItemStyle}"
                        IsDragDropEnabled="True" Background="{StaticResource AccentBrush}" Padding="5"/>
            </DockPanel>
        </Border>
 
        <!--Order-->
        <Border BorderBrush="#C8C9CC" BorderThickness="2" CornerRadius="6" Margin="46 46 0 46"
                Background="White" Grid.Column="1">
            <DockPanel>
                <Border DockPanel.Dock="Top"
                        Background="{StaticResource AccentBrush}" CornerRadius="4 4 0 0">
                    <TextBlock Text="Order" Foreground="{StaticResource MainBrush}" Margin="20 5 5 5" FontSize="14" />
                </Border>
                 
                <!--NOTE: The GridView is a drop target, we set the AllowDrop to true.-->
                <telerik:RadGridView x:Name="orderView" dragDrop:RadDragAndDropManager.AllowDrop="True"
                                     CanUserInsertRows="False" IsReadOnly="True" CanUserFreezeColumns="False"
                                     ShowGroupPanel="False"/>
 
             
            </DockPanel>
        </Border>
 
    </Grid>
</UserControl>




Nick
Telerik team
 answered on 10 Jun 2013
1 answer
278 views
Dear Support,
I'm trying to develop a DocumentManagementSystem. For the time being, we are using Infragistics together with the TxTextControl.
But I found that both are not supporting WPF and MVVM very well, so I asked again for a new evaluation of Telerik and other Thirdpary-controls.

During comparison of the RichTextEditor I found out, that unfortunately (!) your RTF-Box does need significantly more time to load RTF or DOCX-Files than other Controls. Also scrolling ist not very smooth. It doesn't matter if the document has just 1-2 pages or over 10.
So I furthermore compared with your WinForms-Version and found out that the WinForms-RichTextBox is as fast as I would expect.

Referring to this thread : Rich Text Box Performance Issue
might there be a bug which increases loadingtime of documents as well?

I would be very grateful if you could crosscheck with the RTF-Box of Q3 2012. Even better would be, if you could give me a link, where to download the older version in order to check this by myself.

Thank you very much in advance. Telerik would be my first choice, but it really depends on the speed and smootheness of the RTFBox.


PS: Any news about supporting DOC instead of DOCX only? Or do we still have to convert the documents, as you are already mentionening in the older threads?
Petya
Telerik team
 answered on 10 Jun 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?