Telerik Forums
UI for WPF Forum
2 answers
186 views

I'm experiencing some odd behavior when changing the PropertySetMode at runtime. 

 

I have two object types: MyTestClass1 and MyTestClass2. MyTestClass1 has a writeable property IntProp and MyTestClass2 has a readonly property IntProp. If I start in Intersection mode with Item = List<Object> { myTestClass1Obj1, myTestClass1Obj2 } everything works properly. If I then change to PropertySetMode None with Item = myTestClass2Obj, the editor for IntProp will be writeable even though IntProp on myTestClass2Obj has no public setter.

 

See runnable test case below. I am running 2015.2.728

<Window x:Class="WpfApplication1.MainWindow"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"       
        Title="MainWindow" Height="350" Width="525">
    <Grid>
    <StackPanel Orientation="Vertical">
      <Button Click="ButtonBase_OnClick">Change to mode none</Button>
      <telerik:RadPropertyGrid x:Name="rpg"/>
    </StackPanel>
  </Grid>
</Window>

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Text.RegularExpressions;
using System.ComponentModel.DataAnnotations;
using Telerik.Windows.Controls.Data.PropertyGrid;
 
namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
      private readonly MyTestClass test;
    private readonly MyTestClass test2;
    private readonly MyTestClass2 test3;
 
    public MainWindow()
        {
            InitializeComponent();
            rpg.AutoGeneratingPropertyDefinition += new EventHandler<Telerik.Windows.Controls.Data.PropertyGrid.AutoGeneratingPropertyDefinitionEventArgs>(rpg_AutoGeneratingPropertyDefinition);
 
      // test data. IntProp is has a public setter
      test = new MyTestClass() { StringProp = "91das", RequiredField = "abc", IntProp = 10, DateTimeProp = new DateTime(1920, 2, 21) };
      test2 = new MyTestClass() { StringProp = "91das", RequiredField = "abc", IntProp = 10, DateTimeProp = new DateTime(1920, 2, 21) };
 
      // test data. IntProp is read only (no public setter)
      test3 = new MyTestClass2() { StringProp = "91das", RequiredField = "abc", DateTimeProp = new DateTime(1920, 2, 21) };
 
      rpg.Item = new List<Object> {test, test2};
      rpg.PropertySetMode = PropertySetOperation.Intersection;
        }
 
        void rpg_AutoGeneratingPropertyDefinition(object sender, Telerik.Windows.Controls.Data.PropertyGrid.AutoGeneratingPropertyDefinitionEventArgs e)
        {
            (e.PropertyDefinition.Binding as Binding).ValidatesOnDataErrors = true;
            (e.PropertyDefinition.Binding as Binding).NotifyOnValidationError = true;
            (e.PropertyDefinition.Binding as Binding).ValidatesOnExceptions = true;
        }
 
        private ObservableCollection<ValidationError> results;
 
        public ObservableCollection<ValidationError> Results
        {
            get
            {
                if (this.results == null)
                {
                    this.results = new ObservableCollection<ValidationError>();
                }
                return results;
            }
        }
     
    private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
    {
      rpg.PropertySetMode = PropertySetOperation.None;
      rpg.Item = test3;
      // the property grid will now allow setting of test3.IntProp even though there is
      // no public setter
    }
  }
 
 
    public class MyTestClass : IDataErrorInfo, INotifyPropertyChanged
    {
         
        private int intVar;
        private string requiredField;
 
        public int IntProp
        {
            get { return intVar; }
            set
            {
                intVar = value;
                this.OnPropertyChanged("IntProp");
            }
        }
 
        [Required(ErrorMessage = "This field is Required.")]
        public string RequiredField
        {
            get { return requiredField; }
            set
            {
                requiredField = value;
                ValidateProperty("RequiredField", value);
                this.OnPropertyChanged("RequiredField");
            }
        }
 
        private string stringVar;
 
        public string StringProp
        {
            get { return stringVar; }
            set
            {
                stringVar = value;
                this.OnPropertyChanged("StringProp");
            }
        }
 
        private DateTime dateTimeVar;
 
        public DateTime DateTimeProp
        {
            get { return dateTimeVar; }
            set
            {
                dateTimeVar = value;
                this.OnPropertyChanged("DateTimeProp");
            }
        }
 
        [Browsable(false)]
        public string Error
        {
            get { return string.Empty; }
        }
 
        public string this[string columnName]
        {
            get
            {
                if (columnName == "IntProp")
                {
                    return this.IntProp < 100 && this.IntProp > 0 ? string.Empty : "Value should be in the range of (0, 100)";
                }
                if (columnName == "StringProp")
                {
                    return this.StringProp != null && Regex.IsMatch(this.StringProp, @"^[0-9]+[\p{L}]*") ? string.Empty : @"Value should math the regex: ^[0-9]+[\p{L}]*";
                }
                if (columnName == "DateTimeProp")
                {
                    return this.DateTimeProp.Year > 1900 ? string.Empty : "Date should be after 1/1/1900";
                }
                return string.Empty;
            }
        }
 
        protected void OnPropertyChanged(string name)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        public void ValidateProperty(string propName, object value)
        {
            var result = new List<System.ComponentModel.DataAnnotations.ValidationResult>();
            Validator.TryValidateProperty(value, new ValidationContext(this, null, null) { MemberName = propName }, result);
 
            if (result.Count > 0)
            {
               throw new ValidationException(result[0].ErrorMessage);
            }
        }
    }
 
 
  public class MyTestClass2 : IDataErrorInfo, INotifyPropertyChanged
  {
 
    private int intVar;
    private string requiredField;
 
    public int IntProp { get; } = 12;
 
    [Required(ErrorMessage = "This field is Required.")]
    public string RequiredField
    {
      get { return requiredField; }
      set
      {
        requiredField = value;
        ValidateProperty("RequiredField", value);
        this.OnPropertyChanged("RequiredField");
      }
    }
 
    private string stringVar;
 
    public string StringProp
    {
      get { return stringVar; }
      set
      {
        stringVar = value;
        this.OnPropertyChanged("StringProp");
      }
    }
 
    private DateTime dateTimeVar;
 
    public DateTime DateTimeProp
    {
      get { return dateTimeVar; }
      set
      {
        dateTimeVar = value;
        this.OnPropertyChanged("DateTimeProp");
      }
    }
 
    [Browsable(false)]
    public string Error
    {
      get { return string.Empty; }
    }
 
    public string this[string columnName]
    {
      get
      {
        if (columnName == "IntProp")
        {
          return this.IntProp < 100 && this.IntProp > 0 ? string.Empty : "Value should be in the range of (0, 100)";
        }
        if (columnName == "StringProp")
        {
          return this.StringProp != null && Regex.IsMatch(this.StringProp, @"^[0-9]+[\p{L}]*") ? string.Empty : @"Value should math the regex: ^[0-9]+[\p{L}]*";
        }
        if (columnName == "DateTimeProp")
        {
          return this.DateTimeProp.Year > 1900 ? string.Empty : "Date should be after 1/1/1900";
        }
        return string.Empty;
      }
    }
 
    protected void OnPropertyChanged(string name)
    {
      if (this.PropertyChanged != null)
      {
        this.PropertyChanged(this, new PropertyChangedEventArgs(name));
      }
    }
 
    public event PropertyChangedEventHandler PropertyChanged;
 
    public void ValidateProperty(string propName, object value)
    {
      var result = new List<System.ComponentModel.DataAnnotations.ValidationResult>();
      Validator.TryValidateProperty(value, new ValidationContext(this, null, null) { MemberName = propName }, result);
 
      if (result.Count > 0)
      {
        throw new ValidationException(result[0].ErrorMessage);
      }
    }
  }
}
 

 

dafadsf

Chris
Top achievements
Rank 1
 answered on 12 Nov 2015
4 answers
251 views
With xaml
<Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="321*" />
            <ColumnDefinition Width="335*" />
        </Grid.ColumnDefinitions>
        <StackPanel>
            <Button Margin="5" GotFocus="GotFocus">Test</Button>
            <TextBox Margin="5" GotFocus="GotFocus">text</TextBox>
        </StackPanel>
        <telerik:RadPropertyGrid x:Name="pg" Grid.Column="1"
                                 LabelColumnWidth="100" IsGrouped="True" AutoGeneratePropertyDefinitions="True"
                                 telerik:StyleManager.Theme="Vista"/>
    </Grid>
and code

        private void GotFocus(object sender, RoutedEventArgs e)
        {
            pg.Item = sender;
        }
if you switch between controls than you see errors like this
System.Windows.Data Error: 40 : BindingExpression path error: 'ClickMode' property not found on 'object' ''TextBox' (Name='')'. BindingExpression:Path=ClickMode; DataItem='TextBox' (Name=''); target element is 'RadComboBox' (Name=''); target property is 'SelectedValue' (type 'Object')
System.Windows.Data Error: 40 : BindingExpression path error: 'Command' property not found on 'object' ''TextBox' (Name='')'. BindingExpression:Path=Command; DataItem='TextBox' (Name=''); target element is 'TextBox' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'CommandParameter' property not found on 'object' ''TextBox' (Name='')'. BindingExpression:Path=CommandParameter; DataItem='TextBox' (Name=''); target element is 'TextBox' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'CommandTarget' property not found on 'object' ''TextBox' (Name='')'. BindingExpression:Path=CommandTarget; DataItem='TextBox' (Name=''); target element is 'TextBox' (Name=''); target property is 'Text' (type 'String')
Because the propertygrid do not clear bindings after change selected item.
The version is 2011.3.1330.40 Dev

Dilyan Traykov
Telerik team
 answered on 12 Nov 2015
4 answers
150 views
When I right-click outside the area containing the slots,for example, on the header, the context menu that I have defined still appears provided that I have a selected slot or appointment. Is it possible to constrain the context menu to the slot area?
Claire
Top achievements
Rank 1
 answered on 12 Nov 2015
5 answers
212 views

I'm using the commands in the RadWizardCommands class as described Commands page of the documentation for the RadWizard. I'll start by noting that everything works in the application ​at runtime; however, at design-time Visual Studio 2015 reports the use of the commands as errors. I'd love to eliminate this noise, because it's easy for it to obfuscate real problems.

<telerik:RadButton Content="&lt; Back" Command="wizard:RadWizardCommands.MoveCurrentToPrevious" .. />

The errors that are reported are: Invalid value for property 'Command': 'Microsoft.VisualStudio.DesignTools.XamlLanguageService.Semantics.XmlValue'

Yoan
Telerik team
 answered on 12 Nov 2015
1 answer
201 views

Clicking on the Decrease/Increase Handles of a RadSlider normally changes the Slider by the amount of SmallChange.

But what if I have IsSnapToTickEnabled=True and ticks are not equidistant? In this case the buttons don't work properly. For example:

 

<telerik:RadSlider

Minimum="0" Maximum="10"

IsSnapToTickEnabled="True" 

SmallChange="2"

Ticks="2,4,8,13" />

 

leads to the problem that Increase ​Handle works well when navigating from tick 2 to 4, but then nothing more happens and no further click will bring the thump to tick 8 and 13. This is an incorrect behaviour, or am I wrong?

 

Peter, Germany

 

Dinko | Tech Support Engineer
Telerik team
 answered on 12 Nov 2015
6 answers
854 views
Hi,
I have a question about how to implement scenario presented on the picture table.png? There are 2 separate problems. First and more important is how to implement cell spanning in RadGridView? I had some luck with Custom row layout combined with Style selector and DataTriggers. Then for some rows I managed to change layout do display only cell with TextBlock like in the Row 3 on the picture. Is this the right approach? Well, it works then I lose all the standard styling and behavior (like highlight and so on). Is there any possibility to maintain standard row look and span cells?

The second problems is with headers. As you can see the table has some multilevel headers. I was able to create some sort of substitution of the presented header with Column Groups, but it's not the same, eg. Header 6 should span 2. The main struggle is that content cells are connected directly to Headers in second row, 3rd row of headers is only for labeling and is not connected to the table content? 
Leśmian
Top achievements
Rank 2
 answered on 12 Nov 2015
2 answers
137 views
Hi,I am developing with RadSpreadsheet control.I register my custom function to the RadSpreadsheet .When the function evaluates ,I found that each time the EvaluateOverride method execute 3 times.Is there anything wrong here,or it's supposed to do this.I just worry about running efficiency.
Nikolay Demirev
Telerik team
 answered on 12 Nov 2015
4 answers
776 views

Hi,

Our code is using WPF with MVVM pattern. We are using the RadGridView to display the users data in rows with check box option to select/deselect all rows.

In my code I have a class which derives from 

Behavior<RadGridView>

and inside I have 

target.AssociatedObject.SelectedItems.CollectionChanged += target.GridSelectedItems_CollectionChanged;
where target is ​Behavior<RadGridView>

My WPF code related to grid is: 

<telerik:RadGridView x:Name="Users" HorizontalAlignment="Stretch" AutoGenerateColumns="False" ShowColumnFooters="True"  SelectionMode="Extended"><telerik:RadGridView x:Name="Users"Stretch" AutoGenerateColumns="False" ShowColumnFooters="True" SelectionMode="Extended">​

Issue:

When I select all using the top most checkbox in the grid - the event 

GridSelectedItems_CollectionChanged

fires for every item getting selected. So, if grid have 5 users in the grid - the event fires 5 times for selection/deselection of contacts.

 I think collection changed method should fire only one time.

 

Any clarification on this would be appreciated.

Thanks,

Nirav Patel

Nirav
Top achievements
Rank 1
 answered on 11 Nov 2015
1 answer
158 views

Hi,

 I'm using RadTileView and RadFluidContentControl to display small, normal and large views. For some reason the default normal view is displaying correctly but other 2 views are not displayed. Please see below code:

 

<telerik:RadTileViewItem Header="​Test">

                        <telerik:RadFluidContentControl ContentChangeMode="Manual" 
                                                        State="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadTileViewItem}, Path=TileState, Converter={StaticResource FluidContentStateConverter}}">

                                   <telerik:RadFluidContentControl.SmallContent>
                              
                                    <TextBlock Text="{Binding Path=textvalue}" />
                            </telerik:RadFluidContentControl.SmallContent>

                           
                            <telerik:RadFluidContentControl.Content>

                                <TextBlock Text="{Binding Path=textvalue1}"  />
                            </telerik:RadFluidContentControl.Content>

                             <telerik:RadFluidContentControl.LargeContent>
                               
                                <TextBlock Text="{Binding Path=textvalue2}" />

                            </telerik:RadFluidContentControl.LargeContent>

                        </telerik:RadFluidContentControl>

                    </telerik:RadTileViewItem>

 textvalue, textvalue1 and textvalue2 values are assigned in the viewmodel and it is used in the namespace:

 <UserControl

 d:DataContext="{d:DesignInstance viewModels:TestViewModel}"​

... />

 

Could you help me why small and large contents are not displaying?

 

Thanks


​

Martin Ivanov
Telerik team
 answered on 11 Nov 2015
4 answers
453 views
Hello. I'm trying to figure out the proper way to provide editing for a collection of name/type/value things. I was hoping to use DynamicObject, and expose dynamic properties for the properties to be edited. DynamicObject however, as far as I can tell, has no real way to expose more than a member name to consumers (such as RadPropertyGrid.) So, I don't know how to expose the TYPE of the propert to RadPropertyGrid.

What's the best way to go about this? Is DynamicObject suitable?
Chris
Top achievements
Rank 1
 answered on 11 Nov 2015
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
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
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
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
InlineAIAssistant
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?