Telerik Forums
UI for WPF Forum
4 answers
213 views

To make entire tile area draggable, I applied following behavior on RadTileView-

<telerik:RadTileView  IsItemsAnimationEnabled="False"  x:Name="myTileView"
                             ItemsSource="{Binding AvailableChartList,UpdateSourceTrigger=Explicit}" 
                             telerik:RadTileView.ItemContainerStyle="{DynamicResource RadTileViewItemStyle1}"                                  
                             MaximizeMode="Zero">
                    <i:Interaction.Behaviors>
                        <local:RadTilesDragDropBehavior/>
                    </i:Interaction.Behaviors>
</telerik:RadTileView>

-----Behavior------

public class RadTilesDragDropBehavior : Behavior<RadTileView>
{
    private int DragedElementInitialPosition;
    private bool isDragging;
    private int endPosition = -1;
    private RadTileViewItem dragElement;
    protected override void OnAttached()
    {
        base.OnAttached();
        // Insert code that you would want run when the Behavior is attached to an object.        
        DragDropManager.AddDragInitializeHandler(AssociatedObject, OnDragInitialize);
        DragDropManager.AddDragDropCompletedHandler(AssociatedObject, OnDragAndDropCompleted);
        AssociatedObject.PreviewDragOver += MyTileView_PreviewDragOver;
        AssociatedObject.PreviewTilePositionChanged += RadTileView_PreviewTilePositionChanged;
    }
    private void RadTileView_PreviewTilePositionChanged(object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
        if (this.isDragging)
        {
            e.Handled = true;
            var container = e.OriginalSource as RadTileViewItem;
            if (container == this.dragElement)
            {
                this.endPosition = container.Position;
            }
        }
    }
   
    private void OnDragInitialize(object sender, DragInitializeEventArgs args)
    {
        this.isDragging = true;
        var tileView = sender as RadTileView;
        var tileViewItem = args.OriginalSource as RadTileViewItem;
        this.dragElement = tileViewItem;
        this.DragedElementInitialPosition = dragElement.Position;
       
        if (tileViewItem != null && tileView != null)
        {
            args.Data = tileViewItem;
            var draggingItem = new RadTileViewItem
            {
                Style=AssociatedObject.Resources["RadTileViewItemStyle1"] as Style,
                Width = tileViewItem.RestoredWidth,
                Height = tileViewItem.RestoredHeight
            };

            args.DragVisual = draggingItem;
           tileViewItem.Opacity = 100;
           args.AllowedEffects = DragDropEffects.Move;
            args.Handled = true;        
        }
    }

    private void OnDragAndDropCompleted(object sender, DragDropCompletedEventArgs args)
    {
        if (args.OriginalSource.GetType() == typeof(RadTileViewItem))
        {
            this.isDragging = false;
                Point pt = Util.CorrectGetPosition((RadTileView)sender);
                HitTestResult result = VisualTreeHelper.HitTest(AssociatedObject, pt);
                if (result != null)
                {
                    DependencyObject obj = result.VisualHit.ParentOfType<RadTileViewItem>();
                    if (obj != null)
                    {
                        endPosition=((RadTileViewItem)obj).Position;
                        RadTileView parent = args.Source as RadTileView;

                        IEnumerable<RadTileViewItem> itemsToMove = null;

                        if (this.endPosition != -1)
                        {
                            if (this.DragedElementInitialPosition < this.endPosition)
                            {
                                var itemsCollection = ((IList<ChartDetail>)parent.ItemsSource);
                                itemsToMove = itemsCollection
                                     .Select(i => parent.ItemContainerGenerator.ContainerFromItem(i) as RadTileViewItem)
                                     .Where(c => c.Position > this.DragedElementInitialPosition && c.Position <= this.endPosition)
                                     .OrderBy(c => c.Position);

                                foreach (var item in itemsToMove)
                                {
                                    item.Position--;
                                }
                            }
                            else
                            {
                                for (int i = 0; i < this.DragedElementInitialPosition - this.endPosition; i++)
                                {
                                    this.dragElement.Position--;
                                }
                            }
                        }

                        this.endPosition = -1;
                      }
                    else
                    {
                        draggingTile.Opacity = 100;
                    }
                }
                else
                {
                    draggingTile.Opacity = 100;
                }
            }
       }
    
    private void MyTileView_PreviewDragOver(object sender, System.Windows.DragEventArgs e)
    {
        FrameworkElement container = sender as FrameworkElement;
       
            if (container == null)
            {
                return;
            }
            double tolerance = 60;
            double verticalPos = Util.CorrectGetPosition((RadTileView)container).Y;
            double offset = 20;
            ScrollViewer scrollViewer = AssociatedObject.FindChildByType<ScrollViewer>();
            if (verticalPos < tolerance) // Top of visible list?             
            {
                scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset - offset); //Scroll up.             
            }
            else if (verticalPos > container.ActualHeight - tolerance) //Bottom of visible list?             
            {
                scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + offset); //Scroll down.                 
            }       
    }

    protected override void OnDetaching()
    {
        base.OnDetaching();
        // Insert code that you would want run when the Behavior is removed from an object.      
        DragDropManager.RemoveDragInitializeHandler(AssociatedObject, OnDragInitialize);
        DragDropManager.RemoveDragDropCompletedHandler(AssociatedObject, OnDragAndDropCompleted);
        AssociatedObject.PreviewDragOver -= MyTileView_PreviewDragOver;
        AssociatedObject.PreviewTilePositionChanged -= RadTileView_PreviewTilePositionChanged;
    }

}

If I drag Tile By clicking anywhere on the tile and drop anywhere on the RadTileView, it works fine.

But If I try to drag the Tile by clicking on the header area(RadTileViewItem's default draggable area) and drop the tile out of RadTileView, Tile vanishes from the view. (Please refer the attached image to see the issue.)

Please, suggest a way to fix this issue or if there is any other way to make entire tile draggable.

 

 

Dinko | Tech Support Engineer
Telerik team
 answered on 25 Mar 2020
1 answer
364 views

Hello,

I have some problem with Export to Excel for DateTime Format Columns.

Set Column Format:

(this.myGrid.Columns["JPr_MinStart"] as GridViewDataColumn).DataFormatString = "dd/MM/yyyy hh:mm";

 

On ElementExportingToDocument:

01.private void myGrid_ElementExportingToDocument(object sender, GridViewElementExportingToDocumentEventArgs e)
02.{
03.    if (e.Element == ExportElement.Cell)
04.    {
05.        var cellExportingArgs = e as GridViewCellExportingEventArgs;
06.        if (
07.            (cellExportingArgs.Column as GridViewDataColumn).UniqueName == "JPr_MinStart"
08.        )
09.        {
10.            (cellExportingArgs.Column as GridViewDataColumn).DataFormatString = string.Empty;
11.            var parameters = cellExportingArgs.VisualParameters as GridViewDocumentVisualExportParameters;
12.            parameters.Style = new CellSelectionStyle()
13.            {
14.                Format = new CellValueFormat("dd/MM/yyyy hh:mm")
15.            };
16.        }
17.    }
18.}

On ElementExportedToDocument

private void myGrid_ElementExportedToDocument(object sender, GridViewElementExportedToDocumentEventArgs e)
 {
         if (e.Element == ExportElement.Table)
{
      (this.myGrid.Columns["JPr_MinStart"] as GridViewDataColumn).DataFormatString = "dd/MM/yyyy hh:mm";
}
 }

 

If I set DateFormatString, the export to Excel is wrong. It export the value as String and Excel cannot recognize the DateTime column.

If i remove DateFormatString on Exporting and on Exported I set the DateFormat string, the Excel is right but the first line no!

 

I think that is a bug? My WPF version is: 2018.1.220.40

Thank you very much

Martin Ivanov
Telerik team
 answered on 24 Mar 2020
1 answer
78 views
When we click the pin button we expect to see all the panes in the group hidden or pinned.  Instead we are seeing the individual panes being pinned or unpinned.  Is there a way to override this functionality?
Vladimir Stoyanov
Telerik team
 answered on 24 Mar 2020
1 answer
219 views
I want the first column to be the row header, or some way of defining the row header.  I'm auto generating the columns because I have a dynamic number of columns.  Any ideas?
Vladimir Stoyanov
Telerik team
 answered on 24 Mar 2020
6 answers
442 views
Hello,

i want to remove all Styles from the StyleRepository of the current RadDocument and add my own StyleDefinitions.

The adding of StyleDefinitions works fine, but I can't remove the standard Style.
I tried it with
editor.Document.StyleRepository.Clear();
or
foreach (var style in editor.Document.StyleRepository)
editor.Document.StyleRepository.Remove(style);
or
foreach (var style in editor.Document.StyleRepository)
style.IsPrimary = false;

But allways threre are more Styles than my own in the StyleGallery.
Dimitar
Telerik team
 answered on 24 Mar 2020
2 answers
121 views

Hi,

In 001.png,how to change the background of the cells when I press and hold the mouseleftbutton?

the selectionUnit is cell,and the selectionMode is extended.

guo
Top achievements
Rank 1
 answered on 24 Mar 2020
3 answers
90 views

Hello.

I need directly selected the path like 'DeskTop', 'Videos' or other in the custom place pane sometimes in my application.

Is there has a way to return the selected custom place path in custom place pane?

Martin Ivanov
Telerik team
 answered on 23 Mar 2020
4 answers
277 views

Hello,

MergedCellsStyle of my RadGridView is below.I want to chenge the background of the mergedCell when it is selected.But the code dose not work.

How to achieve that?

Thanks.

<Style x:Key="GridViewMergedCell1" TargetType="telerik:GridViewMergedCell" >
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding}" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold"/>
                        </StackPanel>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Background" Value="AliceBlue"/>
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="AliceBlue"/>
                </Trigger>
            </Style.Triggers>
        </Style>
Vladimir Stoyanov
Telerik team
 answered on 19 Mar 2020
3 answers
323 views

I'm trying to only allow users to type in 6 digits integer with prefix "CA", and now I can only type in one leading zero, not multiple zeros. 

Here is my code, and ProjectNumber is a nullable double. 

<telerik:RadMaskedNumericInput                     

Grid.Column="0"                   

Margin="25, 0, 0, 10"                    

Width="100"                   

Mask="CA#####"                   

Placeholder=""                            

AutoFillZeros="False"                   

AutoFillNumberGroupSeparators ="False"                   

IsClearButtonVisible="False"                                       

AllowInvalidValues="True"                   

Validation.ErrorTemplate="{x:Null}"                   

maskedInput:MaskedInputExtensions.Minimum="0"                     

HorizontalContentAlignment="Left"                   

HorizontalAlignment="Left"                                        

Value="{Binding Path=(viewModel:IProjectFolderViewModel.ProjectNumber), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

 

Also, the prefix 'CA' only appears after users click on the input box or type in something. is there anyway that we could show the prefix all the time. 

Martin Ivanov
Telerik team
 answered on 19 Mar 2020
1 answer
246 views
Hello , I hope you are well.

I have a problem and I need help , I'm working on a WPF project with Telerik UI , my issue is turning about CRUD System 

I Have those things : 
 - Entity Model Auto generated 
 - Dynamic RadDataForm with dynamic Data source for each Table in my Entity model.
 - SQL Server DataBase 

When I load my DataContext , the dataform dynamicly generated with Model types ( Ex : text feild for string types , date Picker for DateTime types ... ) unitil now all is good.

First problem : 

So for Float types when I add a new item and leaving the text field empty is working because it's not required in my data annotations but when I put a value and I change my mind after by let the value empty I got the error Validation message " input string format is incorrect " , knowing that my ( int , float ) values in my Model is Nullable ( I tried Nullable<flaot> and float? ) both cases the same error.

Note : I tried with the ( sdk-projects Telerik  and Demos - Telerik UI for WPF ) examples and same result. 

Second problem : 

In the RadDataForm for numeric values do I can't insert decimal numbers normally ? ( Ex: I wanna write 5.2  I found that I have to write 52 and use arrows position between ( 5 and 2 ) and then put the ' point (.) '

Thank you .
Martin Ivanov
Telerik team
 answered on 18 Mar 2020
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
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
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
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
VirtualKeyboard
HighlightTextBlock
Security
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?