Telerik Forums
UI for WPF Forum
1 answer
27 views

I have a record Pitch (see below)

    [TypeConverter(typeof(PitchTypeConverter))]
    public sealed record Pitch(double MinValue, double MaxValue) : IParsable<Pitch>
    {
        public static readonly Pitch Empty = new(0, 0);

        public static Pitch Parse(string s, IFormatProvider provider) 
            => throw new NotImplementedException();
        public static bool TryParse([NotNullWhen(true)] string s, IFormatProvider provider, [MaybeNullWhen(false)] out Pitch result) 
            => throw new NotImplementedException();

        public override string ToString()
            => $"{MinValue}-{MaxValue}";
    }

As you can see , I also have a TypeConverter (currently not fully implemented, but to show the problem it is sufficient).

  public sealed class PitchTypeConverter : TypeConverter
    {
        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) 
            => base.CanConvertFrom(context, sourceType);

        public override bool CanConvertTo(ITypeDescriptorContext context, [NotNullWhen(true)] Type destinationType)
            => destinationType == typeof(string);

        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) 
            => base.ConvertFrom(context, culture, value);

        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
            => value?.ToString() ?? Pitch.Empty.ToString();

        public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) 
            => base.CreateInstance(context, propertyValues);

        public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) 
            => base.GetCreateInstanceSupported(context);

        public override bool IsValid(ITypeDescriptorContext context, object value) 
            => base.IsValid(context, value);

        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) 
            => base.GetProperties(context, value, attributes);

        public override bool GetPropertiesSupported(ITypeDescriptorContext context) 
            => base.GetPropertiesSupported(context);

        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) 
            => base.GetStandardValues(context);

        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) 
            => base.GetStandardValuesExclusive(context);

        public override bool GetStandardValuesSupported(ITypeDescriptorContext context) 
            => base.GetStandardValuesSupported(context);
    }

The Pitch lives inside a ViewModel and is correctly displayed in the RadPropertyGrid, so in that sense everthing works fine.

    [Category("Conditions")]
        [Description("Sets the minimum/maximum allowed pitch limit.")]
        public Pitch PitchLimit
        {
            get => GetProperty(Pitch.Empty);
            set => SetProperty(value);
        }

        [Category("Conditions")]
        public bool RequiresDE
        {
            get => GetProperty<bool>();
            set => SetProperty(value);
        }

 

when I now edit values in the RadPropertyGrid, the RequiresDE works when pressing enter or selecting the checkbox. It doesn't work however when I edit the value for the Pitch property. I can see that the SetProperty for RequiresDE is called, but when editing the PitchLimit the SetProperty is not called.

I honestly out of ideas to find out why the RequiresDE is called and the PitchLimit isn't.

 

Any help is appreciated.

Thanks

 

 

 

 

 

 

Martin Ivanov
Telerik team
 answered on 06 Mar 2025
1 answer
45 views

Hi,

Does anyone know how I can set the text manually in a RadPropertyGrid and a ComboBox? Or also the selectedIndex? I want to manually set ONLY this one element.


               <telerik:RadPropertyGrid AutoGeneratePropertyDefinitions="False"
                                     x:Name="PropertyBenutzer"  
                                     LabelColumnWidth="150" 
                                     MinHeight="50" 
                                     FontFamily="Tahoma" 
                                     FontWeight="Bold" 
                                     FontSize="12" 
                                     DescriptionPanelVisibility="Visible"
                                     CanUserResizeDescriptionPanel="True"
                                     telerik:StyleManager.Theme="Crystal"
                                     NestedPropertiesVisibility="Visible" 
                                     RenderMode="Flat"
                                     IsGrouped="True"
                                     Item="{Binding ElementName=MyPropertyGrid1}" 
                                     Canvas.Left="568" 
                                     >
...
                        <telerik:PropertyDefinition DisplayName="Anrede" OrderIndex="1" GroupName="Benutzer">
                            <telerik:PropertyDefinition.EditorTemplate>
                                <DataTemplate>
                                    <Border>
                                        <telerik:RadComboBox x:Name="ComboBoxAnrede" 
                                                         FontFamily="Tahoma" 
                                                         Width="156" 
                                                         HorizontalAlignment="Left" 
                                                         HorizontalContentAlignment="Center" 
                                                         SelectedItem="{Binding Anrede, Mode=TwoWay}"
                                                         ItemsSource="{Binding AnredeListe}"
                                                         DisplayMemberPath="Anrede"
                                                         IsEditable="False"
                                                         IsEnabled="true"
                                                         IsReadOnly="False"
                                                         MinWidth="30"
                                                         SelectedIndex="0" 
                                                         CanAutocompleteSelectItems="True" 
                                                         CanKeyboardNavigationSelectItems="True"
                                                         >
                                        </telerik:RadComboBox>
                                    </Border>
                                </DataTemplate>
                            </telerik:PropertyDefinition.EditorTemplate>
                        </telerik:PropertyDefinition>

 

 

Stenly
Telerik team
 answered on 09 Dec 2024
0 answers
43 views

Hi Team,

I need to stop refreshing once the filter is applied.

Example.I have lot of items in one panel ,If I selected item1 in that panel and applied filter in the RadPropertyGrid  for some fields.

And then I will select sencond item in the grid.Now,the RadPropertyGrid  should display the filtered fields but it showing entire fileds.

How to achieve this.

Or give me a solution to set the text for the searchasyoutype textbox from codebehind

 

Kanagaraj
Top achievements
Rank 1
 asked on 04 Oct 2024
0 answers
92 views

I created a class with CommunityToolkit.Mvvm package and use ObservableProperty to create properties for this class. But the PropertyGrid  control does not recognize properties created in this way. Are there any way PropertyGrid  can support ObservableProperty?


using CommunityToolkit.Mvvm.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace Test
{
    public partial class DrawingModel : ObservableObject
    {
        public string Name { get; set; }

        [ObservableProperty]
        public double _length;


        [ObservableProperty]
        public double _width;

        [ObservableProperty]
        public double _height;
    }
}

Jian
Top achievements
Rank 1
 asked on 24 Jun 2024
0 answers
66 views
moved to ticket
n/a
Top achievements
Rank 1
 updated question on 26 Jan 2024
0 answers
64 views
I have a class (ItemTree Parent) bound to a RadPropertyGrid. The class also contains a List of it's own type (List<ItemTree> Children). Is it possible to apply the same PropertyDefinitions for both the parent and children?
Will
Top achievements
Rank 1
Iron
 asked on 10 Nov 2023
2 answers
96 views

[edit: I meant "Modal" Editor and not "Model" editor in the title but I can't update]

Hi,

 

as I know you can use a custom modal editor with an Editor attribute that is declared on a property. Is it possible to use a modal editor with a programmatic approach with PropertyDefinition? I have a dynamic class where I do not have the possibility to declare attributes on properties. On the PropertyDefinition class there is an EditorTemplate property. I managed to use this. But only "in cell" and not modal. Is that possible?

Best regards,

Oliver

OBollmann
Top achievements
Rank 2
Iron
 answered on 20 Mar 2023
1 answer
250 views

Hi

I have a RadPropertyGrid, being defined as:

       <telerik:RadPropertyGrid Item="{Binding ObjectBound, Mode=OneWay}" Width="300" Name="propertyGrid2"
                                 Grid.Column="1"
                                 VerticalAlignment="Stretch"
                                 VerticalContentAlignment="Stretch"
                                 NestedPropertiesVisibility="Visible"
                                 AutoGeneratePropertyDefinitions="True"
                                 SelectionMode="Multiple"
                                 PropertySetMode="Intersection"
                                 telerik:PropertySet.ShouldAddNullForNonMatchingValues="True"

 

where I would like to bind 0...n items

 

Let's say all of those items belong to the class Car

 

  public class CarEngine
    {
        public int PowerKW { get; set; }
        public int DisplacementCCM { get; set; }

    }
    public class Car
    {
        public Car()
        {
            Engine = new ();
        }
        public string Manufacturer { get; set; }
        public string Color { get; set; }
        public CarEngine Engine { get; set; }

    }

In the code behind I have a property to bind to the PropertyGrid

 

public object ObjectBound
        {
            get;
            set;
        }

and will create the items like this:

 

  Car c = new Car();
            c.Manufacturer = "Honda";
            c.Engine.PowerKW = 110;
            c.Engine.DisplacementCCM = 1799;
            c.Color = "black";


            Car c2 = new Car();
            c2.Manufacturer = "BMW";
            c2.Engine.DisplacementCCM = 2199;
            c2.Engine.PowerKW = 150;
            c2.Color = "black";

            List<Car> list = new();
            list.Add(c);
            list.Add(c2);

now first, I will bind just one car instance to the RadPropertyGrid:

            this.ObjectBound = c;

Here I can expand the nested engine instance and can write to each field which is absolutety perfect!

Then we have a second use case where I would like to bind to the list with two cars and get their common attributes while differerent properties will be displayed empty:

      this.ObjectBound = list;

Therefore I had choosen "Intersection" for the propertysetmode of the RadPropertyGrid

For the primitive Attributes Color (shared between both cars) and Manufacturer (different) that will work just fine. 

 

 

But as one can see the nested Attribute "Engine" cannot be set as it not able to be expanded! I'd like to set e.g. a common displacement for both of the two cars. How can I realize such a behaviour as it is required from business?

 

thanks!

         
Stenly
Telerik team
 answered on 01 Mar 2023
0 answers
167 views

Hi,

I have a window that has a RadPropertyGrid and UserControl that contains five buttons. I want to make the screen full while clicking on maximize button. Now as I have fixed height and width. Maximize button is not working. Can you please help me out.

<Window x:Class="WPF.Views.NoteEdit"
        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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:customcontrol="clr-namespace:WPF.CustomControl"
        xmlns:local="clr-namespace:WPF.Views"
        mc:Ignorable="d"
        x:Name="vwNoteEditWindow"
        Title="NoteEdit" Height="680" Width="750">
    <Grid Height="564" VerticalAlignment="Top" >
        <Grid HorizontalAlignment="Center">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <telerik:RadLayoutControl
                Name="PropertyGridContainer"
                Margin="5"
                VerticalAlignment="Top"
                HorizontalAlignment="Center"              
                BorderThickness="0"
                Orientation="Vertical">
            </telerik:RadLayoutControl>
        </Grid>

        <Grid VerticalAlignment="Bottom">
            <customcontrol:RadPropertyWindowButtons x:Name="ucPropertyButtons" Height="44" VerticalAlignment="Top" HorizontalAlignment="Center" Loaded="RadPropertyWindowButtons_Loaded" CustomCancelClick="btn_Cancel_Click" CustomExitClick="btn_Exit_Click" />
        </Grid>
    </Grid>
</Window>

 

User control :

<UserControl x:Class="WPF.CustomControl.RadPropertyWindowButtons"
             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:local="clr-namespace:NPTS_WPF.CustomControl"
             xmlns:fa="http://schemas.fontawesome.io/icons/"
             mc:Ignorable="d" 
             d:DesignHeight="45" d:DesignWidth="700">
    <Grid>
        <Grid Uid="radpropertybuttons" Height="39" VerticalAlignment="Bottom" Margin="74,0,-108,0">
            <Button x:Name="btnNormal_Cancel" Margin="0,0,600,10" HorizontalAlignment="Right" Width="80" Height="25" VerticalAlignment="Bottom">
            </Button>

            <Button x:Name="btnNormal_Accept" Margin="0,0,500,10" HorizontalAlignment="Right" Width="80" Height="25" VerticalAlignment="Bottom">
            </Button>

            <Button x:Name="btnNormal_Imperial"  Margin="0,0,370,10" HorizontalAlignment="Right" Width="110" Height="25" VerticalAlignment="Bottom">
            </Button>

            <Button x:Name="btnNormal_Exit" Margin="0,0,270,10" HorizontalAlignment="Right" Width="80" Height="25" VerticalAlignment="Bottom">
            </Button>

            <Button x:Name="btnNormal_Clone" Margin="0,0,170,10" HorizontalAlignment="Right" Width="80" Height="25" VerticalAlignment="Bottom">

            </Button>
        </Grid>

    </Grid>
</UserControl>
Sudeshna
Top achievements
Rank 1
 asked on 06 Feb 2023
0 answers
53 views
Never mind. I figured out the issue 
Sudeshna
Top achievements
Rank 1
 updated question on 26 Jan 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?