Telerik Forums
UI for WPF Forum
3 answers
107 views
Hi Team,

                I have to drag and drop multiple tile view items from one tile view to another tile view. Can you please provide me a sample application?

Regards,
Veeraguru S
       
Zarko
Telerik team
 answered on 30 May 2014
1 answer
221 views
Hello. I found a good example for Zoom And PanOffset Binding in you samples for WPF (called Zooming and Scrolling)

It workes fine if the 2 RadCartesianChart located on the same control and binding the same properties. In my project  I have to create a 2 tabs and put custom user control insite the each tab.

When I select the firs tab i have to change zoom and offset base on the chartView on the second tab.The same for the first tab, it should change properties base on the chart from tab 1. But it doesn't do it correct. It only works if i select the first tab and then select the second tab and change zoom, it will change it everywhere. 

How can i update zoom on the second chart without opening the tab?

I put some small example on the git and i guess it will clarified the situation. https://github.com/Magnona/ChartViewZoomPanOffset
Pavel R. Pavlov
Telerik team
 answered on 30 May 2014
1 answer
138 views
Hi Team Telerik,

I have some issue regarding raddiagram with wpf.

1. I have 2 picture attached as : "grouprotate45.jpg" and "groupnotrotate.jpg"
 - It's rotate normal when i rotate 1 element in raddiram. 
 - But my issue when i group many elements and then i rotate them. The group not rotate but it's only rotate per element in and it's not correct..

2. I have picture as "idplacementcorrect.png" 
 - How to draw an id of button and it's always place in bottom right of button when i rotate it it's rotate too as same in picture. i can draw button as same my picture with code but i don't know how to place it as correct position when element rotate.


Thank you so much !
Pavel R. Pavlov
Telerik team
 answered on 30 May 2014
7 answers
196 views
Hi All,

  i have a requirement to implement d&d functionality for radgridview(only drag) to textBox (only drop) control.so i tried the drag and drop demo application comes with the telerik suite. gridview to listbox is working fine and the problem is don't know how to implement for textbox control and textbox value should be either one of the dragging column of gridview in MVVM pattern.

   
<UserControl x:Class="TelerikDragandDrop.MainWindow"
        xmlns:telerikDragandDrop="clr-namespace:TelerikDragandDrop">
 
    <UserControl.Resources>
        <telerikDragandDrop:MainViewModel x:Key="ViewModel"/>
 
         
        <!--Note: With this style we make the ListBoxItems draggable:-->
        <Style TargetType="ListBoxItem" x:Key="WishlistItemStyle" >
            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
            <Setter Property="telerik:DragDropManager.TouchDragTrigger" Value="TapAndHold"/>
        </Style>
        <Style TargetType="telerik:GridViewRow" x:Key="OrderItemStyle" >
            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
            <Setter Property="telerik:DragDropManager.TouchDragTrigger" Value="TapAndHold"/>
        </Style>
 
        <Style TargetType="{x:Type TextBox}" x:Key="textBoxStyle">
            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="False" />
            <Setter Property="telerik:DragDropManager.TouchDragTrigger" Value="TapAndHold"/>
            <Setter Property="Foreground" Value="#777777" />
        </Style>
         
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
 
        
 
        <!--Order-->
        <Border BorderBrush="#C8C9CC" BorderThickness="2" CornerRadius="6" Margin="46 46 0 46"
                Background="White" Grid.Column="1">
            <DockPanel>
                <Border DockPanel.Dock="Top"
                        Background="{telerik:Windows8Resource ResourceKey=AccentBrush}" CornerRadius="4 4 0 0">
                    <TextBlock Text="Order" Foreground="{telerik:Windows8Resource ResourceKey=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" IsReadOnly="True" Grid.Column="1" Grid.Row="0" Margin="0,0,0,5"
                                     RowIndicatorVisibility="Collapsed" GroupRenderMode="Flat" ItemsSource="{Binding AllApplications, Source={StaticResource ViewModel}}"
                                     RowStyle="{StaticResource OrderItemStyle}" CanUserFreezeColumns=" False" CanUserInsertRows="False"
                                     CanUserReorderColumns="False" CanUserSortColumns="False" ShowGroupPanel="False" Padding="5" AllowDrop="True"
                                     telerikDragandDrop:GridViewDragDropBehavior.IsEnabled="True" Height="115">
                    <telerik:RadGridView.Resources>
                         
                        <DataTemplate x:Key="DraggedItemTemplate">
                            <StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="Dragging:"/>
                                    <TextBlock Text="{Binding CurrentDraggedItem.FirstName}" FontWeight="Bold"/>
                                </StackPanel>
                                 
                            </StackPanel>
                        </DataTemplate>
                    </telerik:RadGridView.Resources>
                </telerik:RadGridView>
            </DockPanel>
        </Border>
 
        <!--Whishlist-->
        <Border BorderBrush="#C8C9CC" BorderThickness="2" CornerRadius="6" Margin="46"
                Background="White" Grid.Column="2">
            <DockPanel>
                <Border DockPanel.Dock="Top"
                        Background="{telerik:Windows8Resource ResourceKey=AccentBrush}" CornerRadius="4 4 0 0">
                    <TextBlock Text="Wishlist" Margin="20 5 5 5" Foreground="{telerik:Windows8Resource ResourceKey=MainBrush}" FontSize="14" />
                </Border>
                <!--NOTE: The ListBox is a drop target, we set the AllowDrop to true.-->
                <ListBox x:Name="wishlistView" Grid.Column="1" Grid.Row="1"
                         SelectionMode="Extended"
                         ItemsSource="{Binding MyApplications, Source={StaticResource ViewModel}}" FontSize="11"
                      
                         ItemContainerStyle="{StaticResource WishlistItemStyle}" Padding="5" AllowDrop="True"
                         telerikDragandDrop:ListBoxDragDropBehavior.IsEnabled="True"
                         telerik:TouchManager.IsTouchHitTestVisible="True">
                    <ListBox.Resources>
                       
                        <DataTemplate x:Key="DraggedItemTemplate">
                            <StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="Dragging:"/>
                                    <TextBlock Text="{Binding CurrentDraggedItem.FirstName}" FontWeight="Bold"/>
                                </StackPanel>
                               
                            </StackPanel>
                             
                        </DataTemplate>
                    </ListBox.Resources>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Width="150">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                               <TextBlock Grid.Row="1" Text="{Binding FirstName}" FontWeight="Bold"
                                   HorizontalAlignment="Center" Foreground="#FF767676"/>
                                <TextBlock Text="{Binding LastName}" Grid.Row="2"
                                   HorizontalAlignment="Center" Foreground="#FF767676"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </DockPanel>
        </Border>
        <TextBox Height="35" Name="TextBox1" Style="{StaticResource textBoxStyle}"  AllowDrop="True"   Width="225" Grid.Column="2" Margin="24,204,13,8"   telerikDragandDrop:TextBoxDragDropBehaviour.IsEnabled="True"  telerik:TouchManager.IsTouchHitTestVisible="True" />
    </Grid>
</UserControl>
public class TextBoxDragDropBehaviour
   {
       private TextBox _associatedObject;
 
       /// <summary>
       /// AssociatedObject Property
       /// </summary>
       public TextBox AssociatedObject
       {
           get
           {
               return _associatedObject;
           }
           set
           {
               _associatedObject = value;
           }
       }
 
       private static Dictionary<TextBox, TextBoxDragDropBehaviour> instances;
 
       static TextBoxDragDropBehaviour()
       {
           instances = new Dictionary<TextBox, TextBoxDragDropBehaviour>();
       }
 
       public static bool GetIsEnabled(DependencyObject obj)
       {
           return (bool)obj.GetValue(IsEnabledProperty);
       }
 
       public static void SetIsEnabled(DependencyObject obj, bool value)
       {
           TextBoxDragDropBehaviour behavior = GetAttachedBehavior(obj as TextBox );
 
           behavior.AssociatedObject = obj as TextBox;
 
           if (value)
           {
               behavior.Initialize();
           }
           else
           {
               behavior.CleanUp();
           }
           obj.SetValue(IsEnabledProperty, value);
       }
 
       // Using a DependencyProperty as the backing store for IsEnabled.  This enables animation, styling, binding, etc...
       public static readonly DependencyProperty IsEnabledProperty =
           DependencyProperty.RegisterAttached("IsEnabled", typeof(bool), typeof(TextBoxDragDropBehaviour),
               new PropertyMetadata(new PropertyChangedCallback(OnIsEnabledPropertyChanged)));
       public static void OnIsEnabledPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
       {
           SetIsEnabled(dependencyObject, (bool)e.NewValue);
       }
 
       private static TextBoxDragDropBehaviour GetAttachedBehavior(TextBox listBox)
       {
           if (!instances.ContainsKey(listBox))
           {
               instances[listBox] = new TextBoxDragDropBehaviour();
               instances[listBox].AssociatedObject = listBox;
           }
 
           return instances[listBox];
       }
 
       protected virtual void Initialize()
       {
           this.UnsubscribeFromDragDropEvents();
           this.SubscribeToDragDropEvents();
       }
 
       protected virtual void CleanUp()
       {
           this.UnsubscribeFromDragDropEvents();
       }
 
       private void SubscribeToDragDropEvents()
       {
           DragDropManager.AddDragInitializeHandler(this.AssociatedObject, OnDragInitialize);
           DragDropManager.AddGiveFeedbackHandler(this.AssociatedObject, OnGiveFeedback);
           DragDropManager.AddDropHandler(this.AssociatedObject, OnDrop);
           DragDropManager.AddDragDropCompletedHandler(this.AssociatedObject, OnDragDropCompleted);
           DragDropManager.AddDragOverHandler(this.AssociatedObject, OnDragOver);
       }
 
       private void UnsubscribeFromDragDropEvents()
       {
           DragDropManager.RemoveDragInitializeHandler(this.AssociatedObject, OnDragInitialize);
           DragDropManager.RemoveGiveFeedbackHandler(this.AssociatedObject, OnGiveFeedback);
           DragDropManager.RemoveDropHandler(this.AssociatedObject, OnDrop);
           DragDropManager.RemoveDragDropCompletedHandler(this.AssociatedObject, OnDragDropCompleted);
           DragDropManager.RemoveDragOverHandler(this.AssociatedObject, OnDragOver);
       }
 
       private void OnDragInitialize(object sender, DragInitializeEventArgs e)
       {
           DropIndicationDetails details = new DropIndicationDetails();
           var listBoxItem = e.OriginalSource as System.Windows.Controls.ListBoxItem ?? (e.OriginalSource as FrameworkElement).ParentOfType<System.Windows.Controls.ListBoxItem>();
 
           var textBox = sender as System.Windows.Controls.TextBox;
           if (textBox != null)
           {
               var item = listBoxItem != null ? listBoxItem.DataContext : textBox.Text;
               details.CurrentDraggedItem = item;
 
               IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);
 
               dragPayload.SetData("DraggedData", item);
               dragPayload.SetData("DropDetails", details);
 
               e.Data = dragPayload;
           }
 
           e.DragVisual = new DragVisual()
           {
               Content = details,
               ContentTemplate = this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
           };
           e.DragVisualOffset = e.RelativeStartPoint;
           e.AllowedEffects = DragDropEffects.All;
       }
 
       private void OnGiveFeedback(object sender, Telerik.Windows.DragDrop.GiveFeedbackEventArgs e)
       {
           e.SetCursor(Cursors.Arrow);
           e.Handled = true;
       }
 
       private void OnDragDropCompleted(object sender, DragDropCompletedEventArgs e)
       {
           var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData");
 
           if (e.Effects != DragDropEffects.None)
           {
               //var collection = (sender as TextBox).Text;
               //collection.Remove(draggedItem);
           }
       }
 
       private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
       {
           var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData");
           var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails;
           var itemsType = (this.AssociatedObject.Text);
 
           //if (details == null || draggedItem == null || draggedItem.GetType() != itemsType)
           //{
           //    return;
           //}
 
           if (e.Effects != DragDropEffects.None)
           {
               var collection = (sender as TextBox);
               if (collection != null) collection.Text = collection.Text;
           }
       }
 
       private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
       {
           //var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData");
           //var itemsType = (this.AssociatedObject.ItemsSource as IList).AsQueryable().ElementType;
 
           //if (draggedItem.GetType() != itemsType)
           //{
           //    e.Effects = DragDropEffects.None;
           //}
 
           //var dropDetails = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails;
           //dropDetails.CurrentDraggedOverItem = this.AssociatedObject;
           //dropDetails.CurrentDropPosition = Controls.DropPosition.Inside;
 
           e.Handled = true;
       }
   }
Nick
Telerik team
 answered on 30 May 2014
1 answer
897 views
Hi there,

we're using the RadGridView in our MVVM application, so no code-behind or explicit C# code talking to the controls -

How can we specify that grouped rows are expanded by default in the XAML?
Grouping is achieved via ColumnGroupDescriptor in our case.

Thanks,
Jay
Yoan
Telerik team
 answered on 30 May 2014
1 answer
99 views
Hi,

I am using 2014.1.428.45 Telerik dll version. In this dll, while i was pasting the text continuously in the Radrichtextbox its simply keep on increasing the memory of the application.

And also I have used memory profiler to detect where the memory leaks.

please find attached files are classes that used for memory leaks.

Can any one please help me regarding this issue ?

Thanks and regards,
Sivalingam.
Petya
Telerik team
 answered on 30 May 2014
3 answers
103 views
Hi,

I am just trying to improve scroll performance, when the RowDetailsVisibilityMode is set to "Visible", because it is slow for complex detail controls.
Now I am doing this:

<DataTemplate x:Key="DetailTemplate">
    <ContentControl/>
</DataTemplate>

In code behind:

List<TextBlock> notInUse = new List<TextBlock>();

public DataListEditor()
{
    InitializeComponent();

    for (int i = 0; i < 100; ++i)
    {
        TextBlock tb = new TextBlock();
        notInUse.Add(tb);
    }

    dataListGrid.LoadingRowDetails += dataListGrid_LoadingRowDetails;
    dataListGrid.UnloadingRowDetails += dataListGrid_UnloadingRowDetails;
}

void dataListGrid_UnloadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
{
    ContentControl c = e.DetailsElement as ContentControl;

    TextBlock tb = c.Content as TextBlock;

    if (tb != null)
    {
        c.Content = null;
        notInUse.Add(tb);
    }
}

void dataListGrid_LoadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
{
    ContentControl c = e.DetailsElement as ContentControl;

    if (c.Content == null)
    {
        Binding b = new Binding("Roles[0].DisplayName");
        b.Source = e.Row.DataContext;

        TextBlock tb = notInUse[0];
        notInUse.RemoveAt(0);

        tb.SetBinding(TextBlock.TextProperty, b);
        c.Content = tb;
    }
}

In other words: I try to recycle detail controls, so that there is no need to recreate them. This works fine, when I am only scrolling. But if I resize the window, the DetailsPresenter of a row seems not to be measured to its content, so the text block is there with the right height, but its visual ancestors have a wrong height and the textblock is not visible. Is there a workaround to solve this?

Thanks
Yoan
Telerik team
 answered on 29 May 2014
8 answers
348 views
Hi,
I follow your demo: http://www.telerik.com/help/wpf/gridview-populating-datavirtualization.html and seems I missing something.

Use code first.

xaml:
-------------------------------
<telerik:RadGridView Grid.Row="1" Name="_grid" ItemsSource="{Binding Contacts}" AutoGenerateColumns="True" 
                             ShowColumnFooters="True"
                             ColumnWidth="*" AlternationCount="2" AlternateRowBackground="#FFEAEFF7" Background="#FFD2DEEF" EditTriggers="None"
                             telerik:StyleManager.Theme="Summer" HorizontalGridLinesBrush="White" VerticalGridLinesBrush="White">

 <telerik:RadDataPager Grid.Row="2" Source="{Binding ElementName=_grid, Path=Items}"
                              DisplayMode="FirstLastPreviousNextNumeric,Text" PageSize="18" />
-------------------------------

ViewModel:
-------------------------------
public VirtualQueryableCollectionView Contacts { get; set; }

public ContactViewModel()
        {
            var db = new PaperCRMContext();
            var query = db.Contacts.OrderBy(x => x.Id);
            Contacts = new VirtualQueryableCollectionView(query) { LoadSize = 10 };
        }
-------------------------------
When I run the project I receive error: 
{"There is already an open DataReader associated with this Command which must be closed first."}

When I remove .OrderBy(x => x.Id) i receive other error: 
{"The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'."}

At last when I remove { LoadSize = 10 }
I receive empty grid

Can someone help me what I miss here?

Best regards,
Saykor


Boris
Telerik team
 answered on 29 May 2014
2 answers
135 views
We are replacing our applications existing HTML editor with the Telerik RadRichTextBox.

One of our users noticed that her font was no longer available in the FontFamily combo.

I discovered that the font she could not find is a *.otf (OpenType) font.

Does the RadRichTextBox support *.otf (OpenType) fonts?
Petya
Telerik team
 answered on 29 May 2014
4 answers
439 views
Hi,,

How to set the selected points in RadCartesianChart with ScatterPointSeries from the View Model?


Thanks,,
Ahmed
Top achievements
Rank 1
 answered on 29 May 2014
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?