Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
XamPropertyGrid bound to PropertyGridPropertyItem(s)
posted

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

Parents
No Data
Reply
  • 2490
    Offline posted

    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.

Children