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

Close event for a RadPane

9 Answers 1131 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Jorge Alberto
Top achievements
Rank 1
Jorge Alberto asked on 18 Dec 2009, 03:51 PM
Hello, I like to prevent the closing of a RadPane, when changes on its content has not been saved, like displaying the message: "Save changes before closing". I can't find the event to attach a handler to it.

Best regards.

9 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 21 Dec 2009, 01:25 PM
Hello Jorge,

I am sending you a sample project, which illustrates how with the PreviewClose event handler you can display a window, which asks for confirmation.
I hope this will work for you.
If you have any further questions please feel free to ask again. 

Greetings,
Konstantina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ogi Ivanov
Top achievements
Rank 1
answered on 14 Apr 2010, 11:23 PM
Hi Konstantina,
I have a WPF solution using the MVVM pattern where I bind the RadPaneGroup of the DocumentHost to an ObservableCollection of RadDocumentPane on the ViewModel. I'm having a difficulty closing these documents from the X button on the right. If I trap the event as descibed in this post, remove the selected item from the collection and set the e.Hadled = true it works fine but only once. After that the button doesn't fire the event any more. How do I close a document pane when the RadPaneGroup is bound to an ObservableCollection on the ViewModel.

Your help is very much appreciated,
Ogi Ivanov
0
Konstantina
Telerik team
answered on 20 Apr 2010, 11:58 AM
Hi Ogi,

Thank you for your question.

Binding the RadPaneGroup is not supported. You can manage the items of the RadPaneGroup via the Items collection.

If you have any other questions please feel free to contact us again.

All the best,
Konstantina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ogi Ivanov
Top achievements
Rank 1
answered on 23 Apr 2010, 09:30 PM
I rosolved this issue to work with the MVVM pattern so I'm sharing it. My requirement was to have a dynamicaly populated tab document collection in the DocumentHost. Using the MVVM pattern I have a ViewModel bound to a Window which contains the RadDocking control. Binding a RadPaneGroup to an observable collection work fine populating the tabs but they cannot be closed using the built-in controls. So I placed a button on the tab header to remove the item from the ObservableCollection. I added a cutom header template to the window resources.
 <Window.Resources> 
    <DataTemplate x:Key="HeaderTemplate">  
        <StackPanel Orientation="Horizontal">  
            <Button Style="{StaticResource ImageButtonStyle}" Command="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}}, Path=DataContext.CloseTabCommand}">  
                <Image Height="14" Width="14" Source="Images/delete.png"/>  
            </Button> 
            <TextBlock Margin="5,0" Text="{Binding}"/>                  
        </StackPanel> 
    </DataTemplate> 
</Window.Resources>   
It uses a custom style ImageButtonStyle to give it a compact look and it calls the command CloseTabCommand on the ViewModel which after running some checks removes the SelectedRadPane from the RadPaneList collection.
<telerikDocking:RadDocking.DocumentHost> 
    <telerikDocking:RadSplitContainer InitialPosition="DockedLeft">  
        <telerikDocking:RadPaneGroup ItemsSource="{Binding Path=RadPaneList}" SelectedItem="{Binding SelectedRadPane,Mode=TwoWay}" /> 
    </telerikDocking:RadSplitContainer> 
</telerikDocking:RadDocking.DocumentHost> 
So the ViewModel has the following properties bound to the xaml
public ObservableCollection<RadDocumentPane> RadPaneList { get; private set; }  
public RadDocumentPane SelectedRadPane { get; set;} 
And in order to add a RadDocumentPane to the collection I do the following which presumes there is a property Title on the ViewModel to bind the header to. It creates a new instance of the control to be displayed in the new tab and binds it to an instance of the respective ViewModel
System.Windows.Data.Binding binding = new System.Windows.Data.Binding("Title");  
RadDocumentPane documentPane = new RadDocumentPane();  
documentPane.SetBinding(RadDocumentPane.HeaderProperty, binding);  
documentPane.SetBinding(RadDocumentPane.ToolTipProperty, binding);  
documentPane.SetResourceReference(RadDocumentPane.HeaderTemplateProperty, "HeaderTemplate");  
documentPane.CanUserClose = false;  
documentPane.CanFloat = false;  
documentPane.ContextMenuTemplate = null;  
 
MyCustomContro myControl = new MyCustomControl();  
documentPane.DataContext = new DocumentPaneViewModel();  
documentPane.Content = myControl;  
 
RadPaneList.Add(documentPane); 

I hope this helps
0
Konstantina
Telerik team
answered on 27 Apr 2010, 05:34 PM
Hello Ogi Ivanov,

Thank you for sharing your solution.

Just keep in mind that if you try to pin/unpin, float and dock the Pane you will get an error, because these actions manipulate the Items collection.

If you have any other questions about our controls please feel free to contact us again.

Best wishes,
Konstantina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rodrigo
Top achievements
Rank 1
answered on 02 Aug 2010, 04:54 PM
Hi, I want to join to the thread and expand it a little, i need to do the same thing that Jorge but the only difference is than Im not using the RadDocking control that you used on the example, Im using only the RadDocumentPane. Is there any property or event that I can use to do this ? Besides, is there any property or event that i can use to know if anything inside the RadDocumentPane was changed, in order to show a message of confirmation if the user wants to close the Pane only if he modified something inside the Pane (ie: changed radiobutton state or combobox value or entered some characters inside a textbox) ?

Thanks and Regards,
0
George
Telerik team
answered on 06 Aug 2010, 06:39 AM
Hello Rodrigo,

You could handle the PreviewClose event for RadDocking and in the body of the handler you could check if RadDocumentPane is closing:

private void RadDocking_PreviewClose(object sender, Telerik.Windows.Controls.Docking.StateChangeEventArgs e)
        {
            if (e.Panes != null && e.Panes.Count() > 0 && e.Panes.ToList()[0].GetType() == typeof(RadDocumentPane))
            {
                // your code goes here
            }
        }
 
What kind of change do you need? We need more detailed information so that we can help you.

Please do not hesitate to contact us if you require any further information.

All the best,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rodrigo
Top achievements
Rank 1
answered on 06 Aug 2010, 03:45 PM
Hi George, first of all thanks for the response, when i said "anything changed inside the RadDocumentPane" i meant to know if any control has changed, i mean, if the user made some modifications, but i really only need to know if any control has changed (besides of its an editable control or not). Regards.
0
George
Telerik team
answered on 10 Aug 2010, 12:28 PM
Hello Rodrigo,

There is no property or event that indicates such change inside of a RadDocumentPane. You need to implement your custom logic to accomplish this. 

Please do not hesitate to contact us if you require any further information.

Kind regards,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Docking
Asked by
Jorge Alberto
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Ogi Ivanov
Top achievements
Rank 1
Rodrigo
Top achievements
Rank 1
George
Telerik team
Share this question
or