hi
in my model property with this name "IsOpen" exist
how to bind this property to IsExpanded of xamTreeGrid.
and when tree is open this property set true else set false
this is my code mut not work
<igi:XamTreeGrid DataContext="{Binding Items}" DataSource="{Binding}" x:Name="xamTreeGrid" ><igi:XamTreeGrid.Resources> <Style TargetType="{x:Type igi:TreeCellValuePresenter}" > <Setter Property="IsExpanded" Value="{Binding IsOpen,Mode=TwoWay}"/> </Style></igi:XamTreeGrid.Resources></igi:xamTreeGrid>
Hi Behzad,
Try adding the text "DataItem" right before your IsOpen property.
"{Binding DataItem.IsOpen, Mode=TwoWay}"
The DataContext for a TreeCellValuePresenter is a DataRecord and inside DataRecord there is a DataItem property. This DataItem is your underlying data object.
hello again
i upload a sample to show my problem
please help me to solve this problem
I'm actually not sure why this isn't working for the TreeCellValuePresenter. In the sample it looks like the binding is getting lost for some reason. For now you can change the style to target DataRecordPresenter and it should work. I'm discussing this with our developers to see why TreeCellValuePresenter doesn't work. Will keep you posted.
<Style TargetType="{x:Type ig:DataRecordPresenter}"> <Setter Property="IsExpanded" Value="{Binding DataItem.IsOpen, Mode=TwoWay}"/></Style>
Hi Alex,
This is a late reply but someone may find it useful.
Currently the DataRecordPresenter doesn't really support two way bindings so during initialization the IsExpanded property is forced to "false" and this then overrides whatever value you have in IsOpen to false. In order to work around this I created a behavior that you can attach to the XamTreeGrid that will initialize the record with the initial value inside IsOpen. After this initialization, two way binding for that record should work as normal. Here is my behavior code:https://gist.github.com/ig-robstoffers/171ca2790aa9ad83316221bb3a9a7db2
Hi,
Sorry for hijacking the thread but I got the same exact question and this thread has answered it for exactly 50 percent as setting IsOpen to true when tree is populated and visible works great.
Another 50 percent is how to make XamTreeGrid actually expand node when IsOpen is set to true upon binding? To reproduce, assign value of true to _isOpen on line 77 in the aforementioned sample's MainWindow.xaml.cs file and run the sample. Nodes will be collapsed in spite of being expanded at once as they are told to.
Thanks,
Alex
The fix for development issue 215236 is available in the latest service release which can be downloaded from the My Keys and Downloads page.
thanks for your post and your support
Looks like there's an issue inside TreeCellValuePresenter which is overriding any bindings applied to IsExpanded through a style. I have logged a development issue for this with the ID 215236. I have also created a private support case for you so that I can link it to the dev issue and let you track its status. The case number is CAS-170471-N5F4T1. You can view it here.
In the mean time, you can use the DataRecordPresenter style I posted in order to get the desired behavior.