Hello,
The following sample style is from the Infragistics Controls & Application Samples.
I have a wpf UserControl that host a XamDataGrid. I'm getting a wpf error: The member Template is not recognized or accessible.
Thank you
<igDP:XamDataGrid.Resources> <Style x:Key="ShowInChartCellStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <Border BorderThickness="0,0,1,0" BorderBrush="{TemplateBinding BorderBrush}"> <CheckBox HorizontalAlignment="Center" IsChecked="{Binding Path=Value, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center" /> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:XamDataGrid.Resources>
Your recommendations have solved my issue.
Thank you Andrew for helping and sharing your knowledge.
Hello User201,
I have taken a look at the sample project that you have provided, and the reason that you currently cannot access the Template property of the CellValuePresenter is because you are missing an assembly reference in this case. The XamDataGrid has a dependency on the InfragisticsWPF4.Editors.v16.1.dll, and so I would recommend adding it to your project to resolve the error you are seeing. It is also worth noting that I would imagine that your project still builds, as the property is actually there - it is just this missing dependency causing the error to be thrown in Visual Studio's XAML editor.
Regarding the Checkbox issue, I would generally recommend against binding to the CellValuePresenter.Value property two-way, especially with a Checkbox control. Essentially what is happening here is that your value is being updated, but it is being updated twice, and so a false checkbox will turn true and then back to false. This is partially due to the binding to CellValuePresenter.Value and partially due to the way we update values in the XamDataGrid cells internally. This can be seen by handling the DataValueChanged event of the XamDataGrid and checking the event arguments for the new value. Note, to handle this event, you need to set the XamDataGrid.FieldSettings.DataValueChangedNotificationsActive property to "True."
In order to work around this issue, I would recommend that you bind to the property on your underlying data item that will represent this Checkbox. This property currently has a private setter, though, which makes it read-only to the XamDataGrid, and so I would recommend either making this public, since you wish to be able to edit it anyway, or make it internal and visible to your window containing your XamDataGrid. You can read about visible internals here: https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(v=vs.110).aspx.
The elements in your CellValuePresenter template have a data context of the underlying DataRecord that contains the presented cell, which has a DataItem property returning your underlying data item. So, you can bind to {Binding DataItem.ECar.IsAvailable} in the case of your attached sample project.
I have attached a modified version of the sample project you sent to demonstrate. I hope this helps.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
I was able to get rid of the error by adding Control.
<Setter Property="Control.Template">
However, if I click on the checkbox, it does not allow to check or uncheck.
Please refer to the attached demo project.