set binding mode for properties

Grids for WPF Forum

Posted 6 years ago by Sasha
Version: 13.1.0582
Avatar

Hi,

My code is:

<propgrid:PropertyGrid x:Uid="PropertiesUserControl" x:Name="PropertiesUserControl" SelectedObject="{Binding SelectedObject}">
     <propgrid:PropertyGrid.PropertyEditors>
          <propgrid:DialogTextBoxPropertyEditor PropertyName="Path"/>
      </propgrid:PropertyGrid.PropertyEditors>
</propgrid:PropertyGrid>

 and in my viewModel I define my properties like this:

  [LocalizedCategory("General")]
  [LocalizedDisplayName("DisplayControlName")]
  [LocalizedDescription("DescControlName")]
   public string ControlName
   {
      get { return _controlName; }
      set
      {
           _controlName = value;
           RaisePropertyChanged("ControlName");
      }
   }

 

I can't figure out, how can I set binding mode for all properties to OneWay in propertyGrid?

Thank you in advance

Comments (4)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sasha,

Can you describe in more detail your use case for this?  Such as are you trying to use PropertyGrid to only display property values read-only to the user?

If so, please see our "Read-Only State" QuickStart sample since it shows how to do that.


Actipro Software Support

Posted 6 years ago by Sasha
Avatar

Hi, I think to set updateSourceTrigger to each property to explicit, will be a better solution,  so I will be able to save changes to properties in my viewModel manually. It should be like this - user sets in propertyGrid controlName. And property in viewModel should be changed only when user will click Save button. When user will click Save button there will be something like :

BindingExpression be = propertyGrid.GetBindingExpression(TextBox.TextProperty);
be.UpdateSource();

[Modified 6 years ago]

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sasha,

Any binding changes would need to be made in all the many editor templates used to drive PropertyGrid, which really would not be a trivial matter.  Especially since custom editor templates can be made (or our own built-in ones fully customized and changed).  So unfortunately that isn't an option.

I would instead recommend that you deep copy whatever object you are editing and then when the Save button is pressed, either copy over the edited object to replace your original one, or copy property value by property value over.


Actipro Software Support

Posted 6 years ago by Sasha
Avatar

Thank you for your help.

The latest build of this product (v2018.1 build 0675) was released 10 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.