Telerik Forums
UI for WPF Forum
3 answers
701 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
157 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
4 answers
116 views

Hello, again!

 

If pdf annotations on rotated pages have the flag /Rotate with the same angle as page angle, they will be displayed wrong.

 

I attached file with this trouble:   http://u.pc.cd/A71rtalK

And 2 screens: Correct.png and Incorrect.png

Annotation "Test2" looks incorrectly

 

Reason for this may be the using 'apprearance stream', which is trying to rotate on an already rotated page. But I am not sure.

Martin
Telerik team
 answered on 15 Oct 2020
5 answers
295 views

We are using the RadFilePathPicker and we can set the theme of the picker control but how do we set the theme of the resulting dialog when the control is opened?  The theme does not seem to carry over.

 

<telerik:RadFilePathPicker DialogType="SaveFile" FilePath="{Binding SaveLocation, Mode=TwoWay}" Margin="0" 
                                               WatermarkContent="No File Selected" VerticalAlignment="Center" Height="30" Grid.Row="4" Grid.Column="1"
                                               telerik:StyleManager.Theme="Office2016Touch"/>          

 

Dinko | Tech Support Engineer
Telerik team
 answered on 14 Oct 2020
5 answers
180 views

Hello!

 

 

If Pdf file contains page with relocated mediabox and cropbox, there are annotations on that page will be in the wrong position.

 

I attached 2 files:

Sample_Correct.pdf - http://u.pc.cd/PCVrtalK

Sample_Incorrect.pdf - http://u.pc.cd/dEI

and 2 screens:

Sample_Correct.png and Sample_Incorrect.png

 

Difference between these files, that incorrect file has moved media and crop boxes. 

Dimitar
Telerik team
 answered on 14 Oct 2020
6 answers
457 views

Hello!

 

I use PdfViewer and in some pdf files I have annotations (comments) to show them for users. But sometimes these annotations are not displayed in the Viewer. In particular we use /FreeText annotations.

I can read these annotations through Annotations property in RadFixedPage, but I can't see them in the Viewer. And if I open the same file in Adobe Reader, I can watch these annotations.

 

I noticed, that if annotation dictionary (/Annot) doesn't contain "appearance stream" in itself (/AP), it won't be displayed in the Viewer. 

For /FreeText annotation, key /AP is Optional and it annotation also contains other keys in annotation dictionary for display itself, such as /DA, /DS and /RC.

Key /DA is "Required" key and should be used like the default appearance if there is no /AP entry.

What should we do to display annotations if there aren't appearance streams for annotations? Because pdf files could be created not only Adobe software.

 

I attached 2 files:

"Before.png" on which you can see text 'Hello'

"After.png" on which you can't see that text.

Difference between these files, that in the "After.png" there is no /AP key in annotation dictionary.

You can see this on other screens: "After_behind.png" and "Before_behind.png".

 

Tanya
Telerik team
 answered on 14 Oct 2020
3 answers
317 views

Hello,

I recently updated from WPF R3 2019 to R3 WPF 2020 and I am having an issue with a custom animation attached to a RadNavigationView. It worked fine under WPF R3 2019, but is now behaving differently. Now, the menu does not always expand horizontally when the pane toggle button is pressed, and when it does, it expands instantly, ignoring the duration time. The number of times the page toggle button needs to be pressed before it expands is not consistent. The same thing happens when trying to collapse the menu, except that it does not collapse instantly. I also tried using your example here, but I get the same behavior. Is there anything I am missing here?

RadNavigationView:

<telerik:RadNavigationView Name="navigationView"
                  Style="{DynamicResource MainNavigationViewStyle}"
                  IsPaneOpen="{Binding IsPaneOpen, RelativeSource={RelativeSource AncestorType=UserControl}, Mode=TwoWay}"
                  ItemsSource="{Binding SubPages}"
                  SelectedIndex="{Binding NavigationToken.SelectedSubPageIndex, Mode=TwoWay}"
                  Background="Transparent"
                  BorderThickness="0"
                  AutoChangeDisplayMode="False"
                  DisplayMode="Expanded"
                  PaneHeaderHeight="0"
                  PaneToggleButtonVisibility="Collapsed"
                  ItemContainerStyle="{DynamicResource MainNavigationViewItemStyle}">

 

Style:

<Style x:Key="MainNavigationViewStyle"
           TargetType="telerik:RadNavigationView"
           BasedOn="{StaticResource RadNavigationViewStyle}">
        <Setter Property="telerik:AnimationManager.AnimationSelector">
            <Setter.Value>
                <telerik:AnimationSelector>
                    <telerik:ResizeAnimation AnimationName="ResizePaneAnimation"
                                     TargetElementName="PaneGrid"
                                     Duration="0:0:0.4"
                                     ResizeMode="Horizontal">
                        <telerik:ResizeAnimation.Easing>
                            <ExponentialEase EasingMode="EaseIn"/>
                        </telerik:ResizeAnimation.Easing>
                    </telerik:ResizeAnimation>
                    <telerik:SlideAnimation AnimationName="MinimalPaneOpenAnimation"
                                    TargetElementName="PaneGrid"
                                    Duration="0:0:0.2"
                                    PixelsToAnimate="250"
                                    Orientation="Horizontal"
                                    Direction="In" />
                    <telerik:SlideAnimation AnimationName="MinimalPaneCloseAnimation"
                                    TargetElementName="PaneGrid"
                                    Duration="0:0:0.2"
                                    PixelsToAnimate="250"
                                    Orientation="Horizontal"
                                    Direction="Out"/>
                </telerik:AnimationSelector>
            </Setter.Value>
        </Setter>
    </Style>
Daniel
Top achievements
Rank 1
 answered on 13 Oct 2020
2 answers
99 views

Hello, again!

 

I have document with incorrect display data on the page. I cann't undestand what the problem is, because of this document has just titul page with Stream (/FlateDecode filter) and some fonts.

 

I attached two screens:

'CorrectView.png' in different pdf viewers

'IncorrectView.png' in PdfViewer

Link for the document:   http://u.pc.cd/tUortalK

Vladimir
Top achievements
Rank 1
Veteran
 answered on 13 Oct 2020
3 answers
129 views

Hi,

I have a problem with visualizating images, which was signed by component (SecureBlackBox).
The final document (which is signed by this component) has image, which is shown vertically mirrored in Telerik component RadPdfViewer as shown in attached file "current.png". I am currently using version 2018.2.1912.45.

In any other pdf viewer (webBrowser, acrobat reader) it looks normal. In newest version of "Demos - Telerik UI for WPF" the PDFViewer showing created pdf normally too, shown in attached file: "demo.png".

PS: I don't know, if it has anything to do with it, but it seems widget, which is connected to created PDF, is using transformation matrix (MatrixPosition) which has attribute hasInverse set on True. But it seems like the value of this matrix doesn't change anything.

I wanted to ask, if this problem was solved/patched in newer version then 2018.2 or If is there some property which is managing this kind of behaviour?

Thanks.

Best regards
Martin.

Martin
Top achievements
Rank 1
 answered on 13 Oct 2020
3 answers
179 views

The requirement is to have a dropdown of string collection which can be different from row to row. So I used ItemsSourceBinding according to the document. But the combox didn't show up when I clicked the cell.

<telerik:GridViewComboBoxColumn Header="Reason"
DataMemberBinding="{Binding MyReason}"
HeaderCellStyle="{StaticResource GridHeaderStyle}"
ItemsSourceBinding="{Binding ValidReasons}"
IsComboBoxEditable="True"
EditTriggers="CurrentCellClick"
IsReadOnly="False"
GroupMemberPath="Check"
/>

"GroupMemberPath" was there before. I added "IsComboBoxEditable", "EditTriggers" and "IsReadOnly" and found nothing changed. I assumed that IsComboBoxEditable can be used if the reason is not found in "ValidReasons".

Dinko | Tech Support Engineer
Telerik team
 answered on 13 Oct 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
Slider
Expander
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
WebCam
CardView
DataBar
Licensing
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
HighlightTextBlock
Security
TouchManager
StepProgressBar
VirtualKeyboard
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?