Telerik Forums
UI for WPF Forum
1 answer
16 views

Hi,

I wanted to know if it is contemplated the possibility of drag and drop from a component such as the RadListBox for example to a RadGridView which has as RowDataTemplate another RadGridView. But, only allow to drag the activity of the RadListBox to the child RadGridView. How could I achieve that?

Thanks in advance.

 


<Window x:Class="ComponentesTestWPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:local="clr-namespace:ComponentesTestWPF"
        mc:Ignorable="d"
        Title="MainWindow">
    <Window.Resources>
        
        <!--Child grid (activities template)-->
        <DataTemplate x:Key="ChildTemplate">
            <Grid MaxWidth="800" HorizontalAlignment="Left" Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <telerik:RadButton Grid.Column="1" Width="25" Height="25" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5,0,0,0" 
                                   Command="{Binding DataContext.Commands[DeleteCommand],RelativeSource={RelativeSource AncestorType=UserControl}}" 
                                   CommandParameter="{Binding }" ToolTipService.ToolTip="Delete">
                    <TextBlock Text="Delete"/>
                </telerik:RadButton>

                <telerik:RadGridView x:Name="ActiviesRadGridView" 
                                     Grid.Column="0" IsBusy="{Binding IsBusy}" ActionOnLostFocus="None" CanUserFreezeColumns="False" 
                                     SelectionMode="Single" MaxHeight="200" MinHeight="150" AutoGenerateColumns="False"
                                     ItemsSource="{Binding Activities, Mode=TwoWay}" 
                                     SelectedItem="{Binding SelectedActivity, RelativeSource={RelativeSource AncestorType=UserControl}, Mode=TwoWay}"
                                     FrozenColumnsSplitterVisibility="Collapsed" CanUserDeleteRows="True" NewRowPosition="None">

                    <telerik:RadGridView.RowStyle>
                        <Style TargetType="telerik:GridViewRow">
                            <Setter Property="telerik:DragDropManager.AllowDrag" Value="True" />
                        </Style>
                    </telerik:RadGridView.RowStyle>

                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding DescActivity}" Width="*" TextWrapping="Wrap" IsReadOnly="True"/>
                    </telerik:RadGridView.Columns>

                    <telerik:RadGridView.Resources >
                        <Style TargetType="telerik:GridViewRow" >
                            <Setter Property="AllowDrop" Value="True"/>
                            <Setter Property="telerik:DragDropManager.AllowDrag" Value="True"/>
                            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True"/>
                        </Style>
                    </telerik:RadGridView.Resources>

                </telerik:RadGridView>

            </Grid>
        </DataTemplate>
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        
        <!--Main grid (groups)-->
        <telerik:RadGridView x:Name="GroupsGridView"  Grid.Column="0"
                             SelectionMode="Extended" Margin="0,5,5,0" ActionOnLostFocus="None" CanUserFreezeColumns="False" 
                             ItemsSource="{Binding Group, Mode=TwoWay}" 
                             SelectedItem="{Binding SelectedGroup, Mode=TwoWay}"              
                             RowDetailsTemplate="{StaticResource ChildTemplate}" IsBusy="{Binding IsBusy}">

            <telerik:RadGridView.Columns>
                <telerik:GridViewToggleRowDetailsColumn ExpandMode="Multiple"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Description}" Width="*" TextWrapping="Wrap" IsReadOnly="True"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Quantity}" Width="Auto" TextWrapping="Wrap" IsReadOnly="True"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Info}" Width="Auto" TextWrapping="Wrap" IsReadOnly="True"/>
            </telerik:RadGridView.Columns>

            <telerik:RadGridView.Resources >
                <Style TargetType="telerik:GridViewRow" >
                    <Setter Property="AllowDrop" Value="False"/>
                    <Setter Property="telerik:DragDropManager.AllowDrag" Value="False"/>
                    <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="False"/>
                </Style>
            </telerik:RadGridView.Resources>
            
        </telerik:RadGridView>

        <!--ListBox (activities)-->
        <telerik:RadListBox x:Name="ActivitiesListBox" Grid.Column="1" Width="200" ItemsSource="{Binding ActivitiesList}" />
        
    </Grid>
</Window>


Stenly
Telerik team
 answered on 10 Jun 2024
1 answer
11 views

   I have a PDF file that's been imported into a MemoryStream object and now I need to display it using the Telerik UI for WPF pdfViewer control.  The existing documentation says that you can create a PdfDocumentSource object and bind the pdfViewer.DocumentSource to that.  However, either PdfDocumentSource no longer exists, or I can't figure out what the correct Namespace is.

   I'm using TelerikUI for WPF v2024 Q2.  However changelogs for 2020 (https://docs.telerik.com/devtools/wpf/controls/radpdfviewer/changes-and-backward-compatibility/backward-compatibility)  say that: 

Changed
Obsolete constructors of Telerik.Windows.Documents.Fixed.PdfDocumentSource:

PdfDocumentSource(Uri uri, FormatProviderSettings settings)
PdfDocumentSource(Stream stream, FormatProviderSettings settings)
What to do now
Use the overloads that accept Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.PdfImportSettings instead.

   I've also read that there is some kind of merge going on trying to replace the previous PDF code with Telerik.Windows.Documents.Fixed .  In any case, I can't seem to figure out how to go from a MemoryStream to something that the pdfViewer.DocumentSource likes.  

   Can anyone help with a very basic code sample to take a PDF as a memorystream and create something that pdfView.DocumentSource will accept?  Thank you!

 

Dimitar
Telerik team
 answered on 07 Jun 2024
1 answer
17 views

Hey guys! We are considering using RadGridView in our apps, but we have figure out next things: 

1. Is it possible to always keep a row in Non edit mode? In other words a user should double click on cells every time when he wants to edit a cell despite the selected row.
2. Is it possible to keep RadCheckBoxColumn is the edit mode? In this case a user should check or uncheck a checkbox by single click. 
3. Is it possible to go next row by Enter key and if it's the last row a new row should be added?
4. Does RadGridView have a functionality to select a column by clicking on the column header?

 
Stenly
Telerik team
 answered on 05 Jun 2024
1 answer
3 views
I am using the RadAutoCompleteBox control in a WPF application and need assistance with configuring it to search for items based on the Name property, but display the values from the Key property.
Stenly
Telerik team
 answered on 05 Jun 2024
2 answers
14 views

Hi. Curently I faced with an issue that I cannot correctly hide tab if I have only one RadPane in the window.

What I am trying to to is the following: I wish to have PaneHeader if I have only one RadPane in the group and hide it and show tabs if more thatn one RadPane. Also I want to completely hide everything if this RadPane is inside ToolWindow. (Similar to Bottom template, but with differ that tabs are on top)

What I have currently:

 

It works when I undock it to ToolWIndow, but fails when I dock it again in the right/left parts of the docking control. Seems binding in the trigger simply does not work.

I am attaching my TopRadPane group Template. Please, point me what I am doing wrong:

 


<ControlTemplate x:Key="RadPaneGroupTopControlTemplate" TargetType="telerikDocking:RadPaneGroup">
        <Grid>
            <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <dock:RadGridResizer x:Name="DockResizer" Placement="Left" ShowsPreview="True" Visibility="Collapsed"/>
        <Border
                x:Name="HeaderTabs"
                Grid.Column="1">
            <Grid x:Name="ItemsContainer" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <ItemsPresenter x:Name="ItemsPresenterElement" Margin="0"/>
                <telerik:RadButton x:Name="CloseButton"
                                   Grid.Column="1"
                                   Command="telerikDocking:RadDockingCommands.Close"
                                   Style="{StaticResource RadButtonDocumentCloseStyle}"
                                   Visibility="{Binding IsEnabled, RelativeSource={RelativeSource Self}, Converter={StaticResource BooleanToVisibilityConverter}}"/>
            </Grid>
            <Border.Style>
                <Style TargetType="Border">
                    <Setter Property="BorderThickness" Value="1" />
                    <Setter Property="Visibility" Value="Visible"/>
                    <Style.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadPaneGroup}, Path=IsInToolWindow}" Value="true" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadPaneGroup}, Path=IsSingleItem}" Value="true" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Visibility" Value="Collapsed" />
                        </MultiDataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            
        </Border>
        <dock:PaneHeader Grid.Column="1" 
                         x:Name="HeaderElement" 
                         SelectedPane="{TemplateBinding SelectedPane}"
                         Visibility="Collapsed">
            <!-- <dock:PaneHeader.Style> -->
            <!--     <Style TargetType="dock:PaneHeader" BasedOn="{StaticResource PaneHeaderStyle}"> -->
            <!--         <Setter Property="Visibility" Value="Collapsed"/> -->
            <!--         <Style.Triggers> -->
            <!--             <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadPaneGroup}, Path=., Converter={StaticResource HeaderVisibilityConverter}}" Value="True"> -->
            <!--                 <Setter Property="Visibility" Value="Visible"/> -->
            <!--             </DataTrigger> -->
            <!--         </Style.Triggers> -->
            <!--     </Style> -->
            <!-- </dock:PaneHeader.Style> -->
        </dock:PaneHeader>
        <Border x:Name="BorderVisual"
                Grid.Column="1"
                Grid.Row="1"
                Grid.RowSpan="1"
                BorderThickness="{TemplateBinding BorderThickness}"
                BorderBrush="{TemplateBinding BorderBrush}"
                Background="{TemplateBinding Background}"/>
        <Border x:Name="AccentBorderVisual"
                Grid.Column="1"
                Grid.Row="1"
                Grid.RowSpan="1"
                BorderThickness="{TemplateBinding BorderThickness}"
                BorderBrush="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(helpers:ThemeHelper.CheckedBrush)}"
                Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedPane.IsActive, Converter={StaticResource BooleanToVisibilityConverter}}"/>
        <Grid Grid.Row="1" Grid.Column="1">
            <ContentPresenter x:Name="ContentElement"
                    Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsContentPreserved, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
                    ContentTemplate="{TemplateBinding SelectedContentTemplate}"
                    ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                    Margin="{TemplateBinding Padding}"/>
            <Grid x:Name="ContentElementsPanel" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsContentPreserved, Converter={StaticResource BooleanToVisibilityConverter}}"/>
        </Grid>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="SplitterPosition">
                <Trigger.Value>
                    <Dock>Left</Dock>
                </Trigger.Value>
                <Setter TargetName="DockResizer" Property="Visibility" Value="Visible"/>
                <Setter TargetName="DockResizer" Property="Grid.RowSpan" Value="3"/>
                <Setter TargetName="DockResizer" Property="Placement" Value="Left"/>
                <Setter TargetName="DockResizer" Property="MinWidth" Value="10"/>
            </Trigger>
            <Trigger Property="SplitterPosition">
                <Trigger.Value>
                    <Dock>Top</Dock>
                </Trigger.Value>
                <Setter TargetName="DockResizer" Property="Visibility" Value="Visible"/>
                <Setter TargetName="DockResizer" Property="Grid.ColumnSpan" Value="2"/>
                <Setter TargetName="DockResizer" Property="Placement" Value="Top"/>
                <Setter TargetName="DockResizer" Property="MinHeight" Value="10"/>
                <Setter TargetName="DockResizer" Property="VerticalAlignment" Value="Top"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="ContentElement" Property="Opacity" Value="{telerik:Office2019Resource ResourceKey=DisabledOpacity}"/>
                <Setter Property="Foreground" Value="{telerik1:Office2019Resource ResourceKey=DisabledForegroundBrush}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

Denis
Top achievements
Rank 1
Iron
 answered on 04 Jun 2024
1 answer
12 views

I have a list of <Data>, which I use to bind to a VirtualGrid
Data: 

   -Value [InnerData]: 

      -- Name [string]

      -- Description [string]

 

I use CellTemplateNeeded event handler to select a DataTemplate for the columns : 

private void RadVirtualGrid_CellTemplateNeeded(object sender, CellTemplateEventArgs e)

{

e.DataTemplate = this.Resources["Template"] as DataTemplate;

}

        <DataTemplate x:Key="Template">
            <StackPanel>
                <Label Content="{Binding Name}" />
                <Label Content="{Binding Description}" />
            </StackPanel>
        </DataTemplate>


And then I use CellValueNeeded to set the Value:

private void RadVirtualGrid_CellValueNeeded(object sender, CellValueEventArgs e)

{

e.Value = viewModel.List[e.RowIndex].Value;

}


So, basically I want to be able to "bind" an object to the Value of the Column.

Then, I want to display multiple properties of the object in the DataTemplate. 

 

It works fine with string data, for e.g.:

e.Value = viewModel.List[e.RowIndex].Value.Name

<Label Content="{Binding }" />


It doesn't work with objects:

e.Value = viewModel.List[e.RowIndex].Value

<Label Content="{Binding Name}" />

A workaround was to "bind" to a string which contains both properties, $"{name}--#--{description}", then use a converter to get the name and description and display it. 
But, I want to be able to pass an object, as I might need to display multiple properties. 

Is there a limitation here? Can you recommend a better way to do it? 

Thanks 

Mihai Adrian
Top achievements
Rank 1
Iron
 answered on 04 Jun 2024
0 answers
6 views

In my project, there is radrichtextbox. I am trying to change fontfamily and basealignment of the text present inside the radrichtextbox whenever that radrichtextbox loads using below code.

radRichTextBox.FontFamily = new System.Windows.Media.FontFamily("Symbol");
radRichTextBox.ChangeBaselineAlignment(Telerik.Windows.Documents.Model.BaselineAlignment.Subscript);

 

But I see no change in the text. Am I missing something?

Shraddha
Top achievements
Rank 1
 asked on 04 Jun 2024
1 answer
18 views

Hi,

I'm using a RadMultiColumnComboBox and can't seem to be able to set the validation error template to Tooltip using:

telerik:ValidationErrorTemplateHelper.DisplayMode="ToolTip"

It always set the validation message on the right of the control, and in my case it's being clipped by the windows limits.

This usually works great on all other controls.

Thank you for your help

Stenly
Telerik team
 answered on 03 Jun 2024
0 answers
5 views

I'm getting a null reference exception when closing one of the pane and could not figure out why it is null in the RemovePane(RadPane pane) method.

We have override to that method,

protected override void RemovePane(RadPane pane)
        {
            if(pane.Header.ToString().ToLower()=="digital" || pane.Header.ToString().ToLower() == "analog")
                SaveDebugPaneLayout(pane);
            pane.DataContext = null;
            pane.Content = null;
            pane.ClearValue(RadDocking.SerializationTagProperty);
            pane.RemoveFromParent();
        }

And also the CreatePaneForItem method,

protected override RadPane CreatePaneForItem(object item)
        {
            var viewModel = item as DebugPaneViewModel;
            if (viewModel != null)
            {
                var pane = viewModel.IsDocument ? new RadDocumentPane() : new RadPane();

                pane.DataContext = item;
    
                if (viewModel.ContentType != null)
                {
                    if (viewModel.GetType().ToString().EndsWith("EditorViewModel")) 
                    {
                        if (pane.Content == null)
                        {
                            dynamic obj = Activator.CreateInstance(viewModel.ContentType);
                            pane.Content = obj;
                            obj.DataContext = viewModel;
                        }
                    }
                    else
                    {
                        pane.Content = Activator.CreateInstance(viewModel.ContentType);
                    }
                }

                RadDocking.SetSerializationTag(pane, viewModel.ID);
                return pane;
            }

            return base.CreatePaneForItem(item);
        }
How can I know which pane is null when it is executing the RemovePane(). I tried looking at when panes are being added but did not see anything suspicious.
boon
Top achievements
Rank 1
 asked on 31 May 2024
1 answer
9 views
A
Dear All,

I am using the RadAutoCompleteBox as follows. I would like to display all Products when pressing the "Keyboard Down Arrow" on the RadAutoCompleteBox. Is this possible?

 

<telerik:RadAutoCompleteBox Height="23" Width="180" Background="#FFEDF4AB" Margin="3,0,0,0" ItemsSource="{Binding Products}" SelectedItem="{Binding SelectedProductItem, Mode=TwoWay}" SelectionMode="Single" TextSearchMode="StartsWith" SearchText="{Binding Name, Mode=TwoWay}" TextSearchPath="Name" DisplayMemberPath="Name" AutoCompleteMode="Suggest" > <telerik:RadAutoCompleteBox.DropDownItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="Black" Width="200" /> </StackPanel> </DataTemplate> </telerik:RadAutoCompleteBox.DropDownItemTemplate> <Behaviors:Interaction.Triggers> <Behaviors:EventTrigger EventName="SelectionChanged"> <Behaviors:InvokeCommandAction Command="{Binding SelectProductCommand}" /> </Behaviors:EventTrigger> </Behaviors:Interaction.Triggers> </telerik:RadAutoCompleteBox>
Dimitar
Telerik team
 answered on 31 May 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?