This is a migrated thread and some comments may be shown as answers.

Enable/disable SettingsPane on a per shape basis

8 Answers 276 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 20 Jul 2012, 02:40 PM
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

8 Answers, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 23 Jul 2012, 09:46 AM
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.

0
Robert
Top achievements
Rank 1
answered on 23 Jul 2012, 11:23 AM
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
0
Robert
Top achievements
Rank 1
answered on 24 Jul 2012, 02:34 PM
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
0
Alex Fidanov
Telerik team
answered on 26 Jul 2012, 07:01 AM
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.

0
Robert
Top achievements
Rank 1
answered on 26 Jul 2012, 10:35 AM
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
0
Alex Fidanov
Telerik team
answered on 30 Jul 2012, 07:26 AM
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.

0
Darko
Top achievements
Rank 1
answered on 26 Jul 2017, 11:47 AM

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>

0
Martin Ivanov
Telerik team
answered on 28 Jul 2017, 08:13 AM
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.
Tags
Diagram
Asked by
Robert
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Robert
Top achievements
Rank 1
Darko
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or