Enable/disable SettingsPane on a per shape basis

9 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
    637 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. 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
  4. 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
  5. Alex Fidanov
    Admin
    Alex Fidanov avatar
    637 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.

  6. 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
  7. Alex Fidanov
    Admin
    Alex Fidanov avatar
    637 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.

  8. Darko
    Darko avatar
    15 posts
    Member since:
    Sep 2008

    Posted 26 Jul in reply to Robert Link to this post

    Hi,

    how could you blend out the button?

     

    when using this in my MainWindows.xaml the button of Settingspane still occure when i click on a shape.

                    <primitives:ItemInformationAdorner.AdditionalContent><telerik:SettingsPane Diagram="{Binding ElementName=diagram}" Visibility="Collapsed"/></primitives:ItemInformationAdorner.AdditionalContent>

  9. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1410 posts

    Posted 28 Jul Link to this post

    Hello Darko,

    The Visibility property of the SettingsPane is internally set when a shape is selected. So, you can't use it to hide the button. There are couple of approaches which I could suggest you to achieve your requirement.
    • If you don't want to show the settings pane you can remove it from the AdditionalContent and re-add it again when necessary.
    • The other approach is to handle the PreviewAdditionalContentActivated event of the diagram. This way you can prevent the button from showing.
      private void diagram_PreviewAdditionalContentActivated(object sender, Telerik.Windows.Controls.Diagrams.AdditionalContentActivatedEventArgs e)
      {
          e.Handled = true;
      }

    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top