Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
205
Binding to AllowEdit Field Setting
posted

Hi,

I apologise in advance for what's probably a simple WPF data binding question.

I'm trying to bind the AllowEdit field setting on the XamDataGrid to some property on my control's data context, but I can't find the right syntax. What I've got is something like the following:

<UserControl>

  <XamDataGrid>

    <DataPresenter:XamDataGrid.FieldSettings>

      <DataPresenter:FieldSettings AllowEdit="{Binding MyAllowEdit}" />

    </DataPresenter:XamDataGrid.FieldSettings>

    ...

  </XamDataGrid>

</UserControl>

Where MyAllowEdit is a property on the object that is the DataContext of my User Control.

I've tried a number of different bindings, but I just can't figure out how to do it.

Cheers,

Adam

Parents
  • 2426
    Suggested Answer
    posted

    Hello Adam,

    You are most likely not getting change notification because the FieldSettings object is not part of the Visual Tree. In circumstances like this, I typically suggest that people handle the PropertyChanged event of their DataContext on their Window or UserControl and set the property manually:

            void myDataContext_PropertyChanged(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "MyAllowEdit")
                {
                    //check new value and apply settings to the grid
                }
            } 

    Hope that helps.

Reply Children