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
1160
CellValuePresenter binding issue
posted

Hi,

Our ui requires that we construct complex objects that contain a collection of "sub-objects" and bind them to a XamDataGrid in code via UnboundField objects.  A property of the sub-object is then displayed in the ui (Factor in this case). This works perfectly with changes in the ui correctly being made to the underlying sub-object.  This sub-object contains an Error property which contains the result of any edit rules validation.  When I try to bind the Error property to the UnboundField ToolTip property in a way similar to how the Factor property was bound it always fails.  Below is the code that builds the columns for the ui:


foreach (BusinessRevisionFactorColumn brfCol in columns)

{

UnboundField uf = new UnboundField(); //string.Format("Hrs[{0}]", i));

uf.BindingPath = new PropertyPath(string.Format("FactorsArray[{0}].Factor.Factor", i));

uf.BindingMode =BindingMode.TwoWay;

uf.Label = brfCol.Name;

Binding ttBinding = new Binding()

{

Path =new PropertyPath(string.Format("FactorsArray[{0}].Factor.Error", i)),

RelativeSource =new RelativeSource(RelativeSourceMode.Self)

};

BindingOperations.SetBinding(uf, UnboundField.ToolTipProperty, ttBinding);

uf.DataType =typeof(double);

uf.Settings.LabelTextWrapping =TextWrapping.Wrap;

uf.Settings.CellValuePresenterStyle = (Style)idgvFactors.FindResource("FactorCellsStyle");

uf.Settings.AllowResize =false;

fl.Fields.Add(uf);

i++;

}

I need to get access to the Error property in the MouseEnter event of the CellValuePresenter but can't find a way to get to the correct sub-object via the DataContext DataItem since these sub-objects live in a collection/array within the DataItem. I don't need to use the ToolTip if there's a way to get to the correct sub-object via some other mechanism.

Can you point me in a direction to pursue?

Thanks!

Glenn

Parents
  • 138253
    Offline posted

    Hello Glenn,

     

    I am just checking if you got this worked out or you still require any assistance or clarification on the matter.

Reply Children