Is there a way to bring the SelectedItem item into focus in the property grid after being set.
The Grid in xaml below:
<igProp:XamPropertyGrid x:Name="XamPropertyGrid" Grid.Row="1" Grid.Column="2" Margin="2,0,0,3" NameColumnWidth="350" AllowDrop="True" SelectedObject="{Binding ElementName=SpSmTreeView2, Path=ActiveDataItem}" SelectedItem="{Binding Path=DataContext.SelectedProperty, Mode=TwoWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" >
private PropertyGridPropertyItem _selectedProperty; public PropertyGridPropertyItem SelectedProperty { get { return _selectedProperty; } set { if (_selectedProperty != value) { _selectedProperty = value; RaisePropertyChanged(() => SelectedProperty); } } }
Also, is the following code the propert way to set the SelectedProperty when the grid is bound to PropertyGridPropertyItem(s)
var PropertyGridPropertyItem = new PropertyGridPropertyItem(SelectedBluePrintObject as BluePrintViewModel, theMissingSPPropertyName, theSPProperty.CategoryName, typeof(String), theSPProperty.IsReadOnly, false); SelectedProperty = PropertyGridPropertyItem;
Any help will be appreciated. Also, is there a way to insert code snippets with better formatting? Thank you,
Andy
Hello Andy,
Thank you for the code snippet, you have provided.
I will need some more information on your scenario. The SelectedObject is set on the ActiveDataItem on a different control (e.g. XamDataGrid) and when this ActiveDataItem has been changed you want to set the focus on SelectedItem in the XamPropertyGrid (please, also refer to the attached picture as an example)?If this is the scenario you can use the SelectedItemChanged event which will fire after the ActiveDataItem is changed.
SelectedObject="{Binding ElementName=SpSmTreeView2, Path=ActiveDataItem}" SelectedItem="{Binding Path=DataContext.SelectedProperty, Mode=TwoWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" SelectedItemChanged="XamPropertyGrid_SelectedItemChanged">
For better formatting of the code snippets, you can use "[code] your code here [\code]" directly in the editor (please use "/" instead, to see the real code container).
Looking forward to your reply.
Nick,
The scenario you've laid out is close, and I can use the pictures you've pasted to better explain what I am trying to accomplish. Let's use your scenario, and say that the xampropertygrid has 100's of properties, and the InnerText property is way down in the list out of the viewable area. So, now you select an item in the datagrid which sets Innertext as the SelectedItem in the xampropertygrid, but it is still not viewable and way down in the list. Is there a way to give focus to the selected item in the property grid so that it shows up somewhere in the viewable area and also shows as selected (possibly using functionality built into the xampropertygrid).
Currently I am using the FilterText property of the grid to achieve the functionality I am looking for, but was hoping there might be a way to leave all the properties in the grid and move the selected item into view and show it as selected.
Does this make sense? If not, please let me know. Thanks,
Thank you for the detailed description, it was very useful to observe the functionality you want to achieve. You can use the Select() method and after that, update layout of the XamPropertyGrid.
Using your description I have created a sample project with XamPropertyGrid and XamDataGrid, you can find it as an attached file. In this example I have used the last property which is out of the viewable area to set the SelectedItem to it. If you click on a record of the XamDataGrid and click the button, the last property of that ActiveDataItem will be selected and the XamPropertyGrid will scroll to it. Please note, that in this example I have used PropertyGridItem.