We have a hierarchy data model setup through an MVVM pattern. When were loading the child row were unable to bind to the child row to change some of the attributes (visible or not). Basically, on some values we do not want to show the actual value but rather hide the value.
Im attaching a sample so you can see what Im referring to.
Any help will be greatly appreciated...
This is the error you'll see:
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:(no path); DataItem=null; target element is 'UnboundField' (HashCode=16321512); target property is 'Visibility' (type 'Visibility')
Hello,
Thank you for your answer.
In your sample you are binding to TemplatedParent, and this one is used to get a reference to the template parent of the current element. However in your sample (Dock1.zip) I do not see where is the corresponding template.
The following code that is binding a field’s visibility property to a corresponding property from the background, can be used as a possible custom approach:
<igDP:Field Label="SomeLabel" Name="SomeName"><igDP:Field.Visibility><Binding Path="SomeCorespondingProp"Source="{StaticResource DATA_ViewModel}"><Binding.Converter><BooleanToVisibilityConverter /></Binding.Converter></Binding></igDP:Field.Visibility></igDP:Field>
The whole code plus a detailed explanation can be found under the following link:
http://forums.infragistics.com/blogs/josh_smith/archive/2008/06/06/binding-a-xamdatagrid-field-property.aspx
Please take a look through this forum an compare it with your implementation.
Do not hesitate to contact us in case of future concerns regarding the discussed matter
Sincerely,
Ekaterina
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support
We're OK on binding to a property on the data context. The problem is we need to bind the visibility based on the current unboundfield. So, lets say the current field 'Class' had a value 'Y' I would want to show the value; else 'N' I would hide the value.
I updated the unbound field to show you want Im referring to.
Again, Im trying to bind the visibility to the current field's value in a hierarchy data grid
<igDP:UnboundField Label="SomeGenericLabel" BindingPath="Class" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Class, Converter={StaticResource StringBoolToVisible}, ConverterParameter='Hidden'}"></igDP:UnboundField>
Thank you for your answer, now I see the error massage.
I took a look through your code. The line that causes this message to appear is :
<igDP:UnboundField Label="Class" BindingPath="Class" x:Name="field1"
Visibility="{Binding ElementName=field1}">
In this declaration you are trying to bind the Visibility propery to itself and it’s causing an error.
Since I am not sure what is your initial idea in this case I can suggest you to the following link:
There you can find a sample code that performs binding of a field’s visibility to a corresponding property from the viewModel.
Please do not hesitate to contact me in case of future concerns regarding this matter.
I will try the above suggestion.
The error is displayed in the Output of the running application. Please take a look there.
I have been looking into your question and I did not manage to get the mentioned error within the sample attached. Neither the MainWindow nor the HierarchicalGridWindow are causing some unexpected behavior. Would you please if possible double check your sample or perhaps send me some steps to follow in order to get the message that you have given.
Nevertheless this error that you get is very similar to the one disscused in the following forum:
http://blogs.infragistics.com/forums/t/38009.aspx
As you will see, the UnboundField is not presented in the visual tree and therefore no binding can be applied on that element. Such an attempt can cause your error.
Would you please take a look at the provided link and compare the described scenario with your own issue and in case this do not help you, supply me with additional information in order to continue the investigation.
I will be looking forward to hearing from you.