Enable/disable SettingsPane on a per shape basis

7 posts, 0 answers
  1. Robert
    Robert avatar
    17 posts
    Member since:
    Jun 2012

    Posted 20 Jul 2012 Link to this post

    Hi,

    I have added the following to my diagram in order to display the settings pane on my shapes:
    <primitives:ItemInformationAdorner.AdditionalContent>
        <telerik:SettingsPane Diagram="{Binding ElementName=radDiagram}" />
    </primitives:ItemInformationAdorner.AdditionalContent>

    Now I am trying to figure out a way to enable / disable the settings pane on a per shape basis. For example, I want to be able to edit settings of square shapes but not circles. Is this something I can do with the item information adorner?

    Rgds,
    R
  2. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 23 Jul 2012 Link to this post

    Hi Robert,

    One option is to handle the ItemInformationAdorner's IsAdditionalContentVisibleChanged event and collapse/show the visibility of the adorner itself based on the selected items.

    Another option is to inherit the SettingsPane control and override the OnIsActivePropertyChanged method and provide custom logic for showing the settings pane (the IsActive property).

    Please let us know if you have further questions on this.

    Kind regards,
    Alex Fidanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Robert
    Robert avatar
    17 posts
    Member since:
    Jun 2012

    Posted 23 Jul 2012 Link to this post

    Hi Alex,

    Thanks for the pointers, regarding solution 1 how can I get an instance of the ItemInformationAdorner so I can subscribe to the IsAdditionalContentVisibleChanged event?

    Rgds
    R
  5. Robert
    Robert avatar
    17 posts
    Member since:
    Jun 2012

    Posted 24 Jul 2012 Link to this post

    I have ended up binding the SettingsPane's Visibility property to the diagram's selecteditem and used a converter to decide whether or not displaying the settingspane
    Visibility="{Binding Path=Diagram.SelectedItem, RelativeSource={RelativeSource Self},Converter={StaticResource isSettingspaneVisibleConverter}}"


    One thig to note is that if diagram's selection mode is set to Single you have to bind to Diagram.SelectedItem and if diagram's selection mode is set to Multiple you have to bind to Diagran.SelectedItems.

    I would have expected Diagram.SelectedItem to be a subset of Diagram.SelectedItems but it turns out that they're independent.

    R
  6. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 26 Jul 2012 Link to this post

    Hello Robert,

     You can find the adorner through the visual tree (using the visual tree helper or one of our extension helper methods like ChildrenOfType). However, binding to the SelectedItem even seem like a more elegant solution. However, I was not able to reproduce the selection mode issue. No matter of the selection mode, the SelectedItems contains the selected item(s) correctly. Am I missing something?

    Greetings,
    Alex Fidanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Robert
    Robert avatar
    17 posts
    Member since:
    Jun 2012

    Posted 26 Jul 2012 Link to this post

    Hi Alex,

    The thing is that SelectedItem is a dependency property whereas SelectedItems is an IEnumerable therefore is not well suited to bind to because no change notification is raised to the subscribers.

    Rgds,
    R
  8. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 30 Jul 2012 Link to this post

    Hi Robert,

     Although it is a valid point that we make the SelectedItems at least support INotifyPropertyChanged, so that you can bind to the Count property, I think it is best to always use the SelectedItemsChanged event. It will be the same for every selection mode.

    Regards,
    Alex Fidanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready