Telerik Forums
UI for WPF Forum
9 answers
1.0K+ views

Hello

I need a racombobox with checkbox with multiselect and "select all" option, so I used the example from this thread : https://www.telerik.com/forums/radcombobox-with-checkbox-with-multi-select-(using-mvvm)

It works well, but I need it into a radgridview which could have a scrollbar and in this case I got an excepetion when I use the scroll of the radgridview.

It's fire the event OnSelectedItemsPropertyChanged change and so the sub Transfer is called but as the collection changed the Transfer sub crach.

 

I tried to put the radcombobox into a stack panel in order to prevent firing of event but it doesn't work :(

Here the code :

<telerik:RadGridView Margin="6,10,6,32.96" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False" CanUserReorderColumns="False"
                             CanUserResizeColumns="True" CanUserSortColumns="False" CanUserDeleteRows="False" CanUserInsertRows="False" ItemsSource="{Binding Rules}"
                             SelectedItem="{Binding SelectedRule}" IsReadOnly="{Binding OnlyRead}"
                             AutoGenerateColumns="False">
 
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn Header="Jib Geometry" Width="100">
                            <telerik:GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                    <telerik:RadComboBox ItemsSource="{Binding JibGeometryDataContexts}" Margin="5,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center"
                                                 Height="22" AllowMultipleSelection="True" EmptyText="Select jib geometry" Grid.Column="1" IsEditable="False" ItemTemplate="{StaticResource MultiSelectComboTemplate}"
                                                 Style="{StaticResource CheckBoxRadComboBox}" MultipleSelectionBoxTemplate="{StaticResource MultiSelectedBoxTemplate}" DropDownClosed="RadComboBox_DropDownClosed">
                                        <i:Interaction.Behaviors>
                                            <combobox:SelectedItemsBehavior SelectedItems="{Binding SelectedJibGeometryDataContexts}" />
                                        </i:Interaction.Behaviors>
                                    </telerik:RadComboBox>
                                    </StackPanel>
                                </DataTemplate>
                            </telerik:GridViewColumn.CellTemplate>
                        </telerik:GridViewDataColumn>                                             
                        ...
                    </telerik:RadGridView.Columns>
 
                </telerik:RadGridView>

 

crash on :

Public Shared Sub Transfer(ByVal source As IList, ByVal target As IList)
            If source Is Nothing OrElse target Is Nothing Then Return
            target.Clear()
 
            For Each o In source
                target.Add(o)
            Next
        End Sub

 

Do you have any Idea to fix these crashes ?

Thanks

Regards

J-Christophe

Dilyan Traykov
Telerik team
 answered on 16 Oct 2020
2 answers
1.0K+ views

Hi all,

I have a grid that uses the GridViewComboBoxColumn column type.  We're trying to give it very fast action.  We want the cell to commit the edit and exit edit mode immediately after selecting a value in the combo box of the column.

How can this be done?  I see there's a RadMultiColumnComboBox.SelectionChanged event where an EndEdit could be called, but we're not using multi-column combo boxes.

Thanks!
Matt

Matt
Top achievements
Rank 1
Veteran
 answered on 16 Oct 2020
4 answers
209 views

Hello,

 

I have tested a specific .pdf file in Adobe Reader, Chrome and Edge, in all viewers the pdf loads without issues and all text is visible.

This is not the case in PDFViewer, the content is obscured in some way (marked in red rectangles on screens). I have tested it on the demo preview of features.

Would it be possible to fix this issue?

 

I'm attaching  the difference in views example in PDFViewer and Edge.

It is not possible to attach the .pdf file in question, can i provide this file in any other way?

Thank you.

Martin
Telerik team
 answered on 16 Oct 2020
3 answers
334 views

I have a HeaderTemplate that contains two RadPathButtons.

One of the button's PathGeometry is defined in xaml:

PathGeometry="{telerik:RadGlyph Glyph=&#xe13a;}"

 

The other one's PathGeometry is defined using the RadGlyph markup extension:

PathGeometry="{telerik:RadGlyph Glyph={StaticResource GlyphInvertColors}}"

 

When using the markup extension the Visual Studio 2019 (Preview) xaml editor shows error "The resource GlyphInvertColors has an incompatible type"

There are no errors when not using the markup extension.

In both cases it works perfectly at runtime. The errors only appear at Design time.

As of a day or two ago, these errors would disappear if I rebuilt the solution. But now they are persistent and never go away.

Here is the xaml I am using:

<telerik:RadWindow.HeaderTemplate>
    <DataTemplate>
        <DockPanel LastChildFill="False">
            <TextBlock DockPanel.Dock="Left" Text="{StaticResource ApplicationTitle}" VerticalAlignment="Center" Margin="0,0,8,0"/>
            <StackPanel DockPanel.Dock="Right" Orientation="Horizontal" FlowDirection="RightToLeft">
 
                <telerik:RadPathButton Style="{DynamicResource RadPathHeaderButtonStyle}"
                                       PathGeometry="{telerik:RadGlyph Glyph=}"
                                       Command="{Binding DataContext.ShowSettingsDialogCommand, ElementName=mainWindow}"
                                       CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type telerik:RadWindow}}}"
                                       telerik:RadToolTipService.Placement="Mouse"
                                       telerik:RadToolTipService.VerticalOffset="1"
                                       telerik:RadToolTipService.ToolTipContent="Settings">
                    <telerik:RadToolTipService.ToolTipContentTemplate>
                        <DataTemplate>
                            <telerik:RadToolTipContentView>
                                <TextBlock Text="{Binding}" />
                            </telerik:RadToolTipContentView>
                        </DataTemplate>
                    </telerik:RadToolTipService.ToolTipContentTemplate>
                </telerik:RadPathButton>
 
                <telerik:RadPathButton Style="{DynamicResource RadPathHeaderButtonStyle}"
                                       PathGeometry="{telerik:RadGlyph Glyph={StaticResource GlyphInvertColors}}"
                                       Command="{Binding DataContext.TogglePaletteCommand, ElementName=mainWindow}">
                    <telerik:RadToolTipService.ToolTipContentTemplate>
                        <DataTemplate>
                            <telerik:RadToolTipContentView>
                                <TextBlock Text="{Binding}" />
                            </telerik:RadToolTipContentView>
                        </DataTemplate>
                    </telerik:RadToolTipService.ToolTipContentTemplate>
                </telerik:RadPathButton>
 
            </StackPanel>
        </DockPanel>
    </DataTemplate>
</telerik:RadWindow.HeaderTemplate>

 

I'm not certain this is actually an issue with the RadGlyph or RadPathButton. It could very well be a Visual Studio issue. Or, of course, it could be a mistake that I am making (maybe something missing or incorrect in my xaml or maybe I am missing a required dependency. Any ideas would be greatly appreciated.

Don
Top achievements
Rank 1
Veteran
 answered on 15 Oct 2020
1 answer
374 views

Hello!

 

I get exceptions when open some files using method Import() in PdfFormatProvider.

I prepared 1 such file to you for tests: http://u.pc.cd/3TlctalK

Version of libraries which I use is 2020.3.915

 

 

I noticed, that exceptions appears for files with outlines.

There is DestinationConverter object and its method ConvertFromArray where that exception appears.

 

Here is exception message:

Unable to cast object of type "Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfReal" to type "Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfName".

Here is a StackTrace:

   in Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.ExceptionHandling.ExceptionHandler.TryHandle(Exception exception)
   in Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ImportOverride(Stream input)
   in PdfViewer.States.AppStateExtensions.ReadDocumentForTelerik(String filePath)

 

My method:

internal static RadFixedDocument ReadDocumentForTelerik(string filePath)
{
    if (filePath == null)
        throw new ArgumentNullException(nameof(filePath));
 
    using (Stream stream = File.Open(filePath, FileMode.Open, FileAccess.Read))
    {
        var provider = new PdfFormatProvider();
        provider.ImportSettings = PdfImportSettings.ReadOnDemand;
        return provider.Import(stream);
    }
}

 

Using:

var doc = ReadDocumentForTelerik(@"C:\Outline_Down.pdf");

 

Martin
Telerik team
 answered on 15 Oct 2020
8 answers
203 views

I have defined a RadWindow like this:

01.<telerik:RadWindow x:Class="Shell.ShellView"
02.                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
03.                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
04.                   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
05.                   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
06.                   xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
07.                   xmlns:shell="clr-namespace:Shell"
08.                   mc:Ignorable="d"
09.                   d:DesignHeight="450" d:DesignWidth="800"
10.                   d:DataContext="{d:DesignInstance shell:ShellViewModel}"
11.                   Width="800"
12.                   Height="475"
13.                   Header="{Binding Header}"
14.                   WindowStartupLocation="{Binding StartupLocation}"
15.                   navigation:RadWindowInteropHelper.ShowInTaskbar="{Binding ShowInTaskBar}">
16.     [...]
17. 
18.</telerik:RadWindow>

 

Note the bindings on lines 13 - 15.

The corresponding view model looks like this:

01.public class ShellViewModel
02.{
03.    public bool ShowInTaskBar => true;
04. 
05.    public WindowStartupLocation StartupLocation => WindowStartupLocation.CenterScreen;
06. 
07.    public string Header => Resources.MainWindowHeader;
08. 
09.    [...]
10.}

 

As you can see, I am binding the Header, the StartupLocation, and the ShowInTaskBar properties. 

My problem is the following: while the bindings for the Header and ShowInTaskBar do work perfectly, the binding for StartupLocation doesn't. I understand why. 

Can someone tell me what I am missing here?

Thanks in advance!

 

 

Dilyan Traykov
Telerik team
 answered on 15 Oct 2020
2 answers
295 views

The strangest thing is happening with my GridView when I try to add a custom datacolumn with a checkbox in and a GridViewColumn.Header, to add anothner checkbox, that should select all checkboxes in the list, pretty standard. 

I have the code below, but when I click  the "check all"-checkbox, I do not get the Command send to my event handler, nothing happens. Now the strange part

If I, while running the application, change the markup (below) AncestorType={x:Type UserControl}}, to AncestorType={x:Type local:MyView}} it works, I get my event. Hip horray, right? Nope. If I restart the application, nothing happens again, until I change it back to the original and things are working again

 

Why, oh Telerik-Gods, why! :D

snippet below:

 

<telerik:GridViewColumn  >
    <telerik:GridViewColumn.Header>
        <CheckBox IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.IsAllChecked, Mode=TwoWay}"                                                                                   
                    Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.SelectAllRowsCommand}">
              

        </CheckBox>
    </telerik:GridViewColumn.Header>


Dilyan Traykov
Telerik team
 answered on 15 Oct 2020
1 answer
1.4K+ views

Hi,

This is a more general question, not about Telerik controls though I am using them.
(VISUAL STUDIO 2019)
I have a VSTO project (I think the question can be for Winforms projects as well).
I have a WPF project that I want to interact with from the VSTO project and back.
I managed to run (process.start with parameters) the the WPF exe from the VSTO but it's not good enough because I want to be able to communicate between the two projects.
I added the WPF project to the VSTO solution, and added a reference from the VSTO to the WPF and then create a "common project" that both projects reference to be able to pass data in common models.
I am able to run the WPF project from the VSTO (when the user clicks a button, in the UI of the VSTO, I call App.Main() in the WPF project).
The problem is that if I try to use App.Main() again (to call the WPF project again) I get an exception because I can not create a second Application in the appdomain.
Any thoughts on how I can accomplish this (my way or any other way that will let me interact between the two projects).
Thank you
Yaron

Martin Ivanov
Telerik team
 answered on 15 Oct 2020
3 answers
689 views

HI

This is longer post, sorry. First I'll explain what I'm trying to do, and then I'll tell a little about what I have tried.

The Problem

I have an object with a property that consist of a list of strings. Showing it in a RadGridView is not hard.

<RadGridView ...>
  <GridViewBoundColumnBase Header="Tags"  DataMemberBinding="{Binding CategoryTagLabels, Converter={StaticResource ListToStringConverter}}"/>
</RadGridView>

 

The ListToStringConverter basically just runs string.join(",", tags).

Now, that is mighty fine.

 

The problem is that I would like to add filtering. I would for the list of distinct values to be shown, and rows that that has any of the selected values from distinct values present in their CategoryTagLabels should be shown.

My Attempt

I tried to follow Custom Filtering Controls and the FilteringCollectionProperties_WPF from your sample SDK

<RadGridView ...>
  <GridViewBoundColumnBase Header="Tags"  DataMemberBinding="{Binding CategoryTagLabels, Converter={StaticResource ListToStringConverter}}">
    <GridViewBoundColumnBase .FilteringControl>
       <StringListFilterControl FilterMemberName="CategoryTagLabels"/>
    </GridViewBoundColumnBase .FilteringControl>
  </GridViewBoundColumnBase
</RadGridView>

 

StringListFilterControl.xaml

<UserControl x:Class="Core.Controls.ThirdParty.Telerik.StringListFilterControl"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:Core.Controls.ThirdParty.Telerik"
             MinWidth="100" MinHeight="100"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800">
    <StackPanel>
        <ListView ItemsSource="{Binding Values}" x:Name="TagLabels">
 
        </ListView>
        <Button Content="Apply Filter" Click="ApplyFilter"></Button>
        <Button Content="Clear Filter" Click="ClearFilter"></Button>
    </StackPanel>
</UserControl>

 

StringListFilterControl.xaml.cs

public partial class StringListFilterControl : UserControl, IFilteringControl, INotifyPropertyChanged
    {
        private ICollection<string> _values;
        private GridViewBoundColumnBase _column;
        private CompositeFilterDescriptor _filterDescriptor;
 
        public StringListFilterControl()
        {
            InitializeComponent();
 
            this.DataContext = this;
        }
 
        public void Prepare(GridViewColumn columnToPrepare)
        {
            _column = columnToPrepare as GridViewBoundColumnBase;
            if (_column == null)
            {
                return;
            }
 
            var sender = _column.DataControl;
            var columnValues = ((RadGridView)sender).GetDistinctValues(_column, false);
            var values = new List<string>();
            foreach (var item in columnValues)
            {
                if (item == null) continue;
                values.AddRange((IEnumerable<string>)item);
            }
 
            var distinctValues = values.Distinct().ToList();
 
            Values = distinctValues;
        }
 
        public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(
            "IsActive", typeof(bool), typeof(StringListFilterControl), new PropertyMetadata(default(bool)));
 
        public bool IsActive
        {
            get { return (bool) GetValue(IsActiveProperty); }
            set { SetValue(IsActiveProperty, value); }
        }
 
        public ICollection<string> Values
        {
            get => _values;
            set
            {
                _values = value;
                this.RaisePropertyChanged();
            }
        }
 
        public static readonly DependencyProperty FilterMemberNameProperty = DependencyProperty.Register(
            "FilterMemberName", typeof(string), typeof(StringListFilterControl), new PropertyMetadata(default(string)));
 
        public string FilterMemberName
        {
            get { return (string) GetValue(FilterMemberNameProperty); }
            set { SetValue(FilterMemberNameProperty, value); }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        private void ApplyFilter(object sender, RoutedEventArgs e)
        {
            if (_filterDescriptor == null)
            {
                _filterDescriptor = new CompositeFilterDescriptor();
                _filterDescriptor.LogicalOperator = FilterCompositionLogicalOperator.Or;
            }
 
            if (!_column.DataControl.FilterDescriptors.Contains(_filterDescriptor))
            {
                _column.DataControl.FilterDescriptors.Add(_filterDescriptor);
            }
 
            _filterDescriptor.FilterDescriptors.Clear();
            var selectedTagLabels = TagLabels.SelectedItems;
            foreach (var selectedTagLabel in selectedTagLabels)
            {
                var tagLabel = (string) selectedTagLabel;
                var filter = new TagLabelFilterDescriptor
                {
                    FilterMemberName = FilterMemberName,
                    TagLabel = tagLabel
                };
                _filterDescriptor.FilterDescriptors.Add(filter);
            }
 
            IsActive = true;
        }
 
        private void ClearFilter(object sender, RoutedEventArgs e)
        {
            _column.DataControl.FilterDescriptors.Clear();
            IsActive = false;
        }
    }
 
    public class TagLabelFilterDescriptor : IFilterDescriptor
    {
        private static readonly MethodInfo EnumerableCastMethod = typeof(Enumerable).GetMethod("Cast");
        private static MethodInfo GenericContainsMethod = GetGenericContainsMethodInfo();
 
 
        public event PropertyChangedEventHandler PropertyChanged;
        public string TagLabel { get; set; }
        public string FilterMemberName { get; set; }
        public Expression CreateFilterExpression(Expression instance)
        {
            MemberExpression collectionPropertyAccessor = Expression.Property(instance, FilterMemberName);
 
            MethodCallExpression genericCollectionPropertyAccessor = Expression.Call(null
                , EnumerableCastMethod.MakeGenericMethod(new[] { typeof(object) })
                , collectionPropertyAccessor);
 
            ConstantExpression tagLabel = Expression.Constant(TagLabel);
 
            var expression = Expression.Call(
                GenericContainsMethod,
                genericCollectionPropertyAccessor,
                tagLabel);
 
            return expression;
        }
 
        private static MethodInfo GetGenericContainsMethodInfo()
        {
            // get the Enumerable.Contains<TSource>(IEnumerable<TSource> source, TSource value) method,
            // because it is impossible to get it through Type.GetMethod().
            var methodCall = ((MethodCallExpression)
                (
                    (Expression<Func<IEnumerable<object>, bool>>)(source => source.Contains(null))
                ).Body).Method.GetGenericMethodDefinition();
            return methodCall.MakeGenericMethod(typeof(object));
        }
    }

And this actually works and I like that it is (almost) something I can just attach to a column if the property is a list of string. This is nice as I have properties of collections of strings in other tables, so it is nice when it is easy to reuse the code.

Only problem is that I now have to reimplement the filtering UI from scratch. First of I have to make it look like the other filter controls (which is hard enough) but it also mean that any styling done for the standard filtering control, will have to maintained separately for StringListFilteringControl. 

Is there any way to reuse the standard filtering control?

Dinko | Tech Support Engineer
Telerik team
 answered on 15 Oct 2020
4 answers
155 views

Here's my setup:

I have an application view leveraging a caliburn bootstrapper (should be irrelevant for the issue):

<Application x:Class="TestApp.App"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:TestApp"
             xmlns:shell="clr-namespace:TestApp.Shell"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
 
                <ResourceDictionary>
                    <local:Bootstrapper x:Key="Bootstrapper" />
                </ResourceDictionary>
 
                <telerik:FluentResourceDictionary />
 
                <ResourceDictionary Source="/Telerik.Windows.Themes.Fluent;component/Themes/System.Windows.xaml" />
                <ResourceDictionary
                    Source="/Telerik.Windows.Themes.Fluent;component/Themes/Telerik.Windows.Controls.xaml" />
                <ResourceDictionary
                    Source="/Telerik.Windows.Themes.Fluent;component/Themes/telerik.windows.controls.input.xaml" />
                <ResourceDictionary
                    Source="/Telerik.Windows.Themes.Fluent;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
 
            </ResourceDictionary.MergedDictionaries>
 
            <Style TargetType="shell:ShellView" BasedOn="{StaticResource RadWindowStyle}" />
 
        </ResourceDictionary>
    </Application.Resources>
</Application>

Here's my application's shell view:

<telerik:RadWindow x:Class="TestApp.Shell.ShellView"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                   xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                   xmlns:testApp="clr-namespace:TestApp.Shell"
                   Width="800"
                   Height="475"
                   Header="Application title">
 
    <Grid>
 
    </Grid>
 
</telerik:RadWindow>

 

Note in the above code the Header="Application title". When I start that application, it shows the window shown in the attachment, i.e. a window with title "TestApp.Shell.ShellViewModel". If I, however, refactor that with the following binding

Header="{Binding Header}"

 

 

and add the Header property to my view model

using Caliburn.Micro;
 
namespace TestApp.Shell
{
    public class ShellViewModel : Conductor<IScreen>
    {
        public string Header => "Application title";
    }
}

 

then I see the correct application title.

Why can't I just hard-code my application title in my Window's xaml code? What am I doing wrong here?

Martin Ivanov
Telerik team
 answered on 15 Oct 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?