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
Hello Glenn,
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
Hi Stefan,
Thanks for following up. I'll still need assistance as soon as I can find some time to create some sample code. Too many higher priority issues lately.
I am looking forward for your reply.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Worked perfectly!
Thanks for the help and the amazingly quick response.
I have been looking into your sample and I modified it so now it has the functionality you want.
Hope this helps you.
Hi Stefran,
I've finally had some time to create a sample program for you.
I've set a break point in Control_MouseEnter that you'll hit when you mouse over any of the cells containing an amount. That is the point that I need to access the actual underlying object for that specific cell in order to get to its "Error" property. How do I get to that object?