Changing the style of dialog windows

23 posts, 1 answers
  1. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 21 Jan 2011 Link to this post

    Is there a way of changing the RadWindow style that RadScheduleView uses for its dialogs? I have a feeling that it can be done with a custom theme, but I would like to avoid that if possible. Is there an easier way?

    Best regards,
    /Henrik
  2. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 21 Jan 2011 Link to this post

    With RadScheduleView you could even use different controls to show the dialogs, instead of RadWindow. We don't provide a Stype property right now, but in order to customize the windows you could implement the ISchedulerDialogHostFactory in a class and set an instance of this class to the SchedulerDialogHostFactory property of RadScheduleView. In this class you could configure RadWindow as you need. Here is source code of the default ISchedulerDialogHostFactory implementation:
    internal class SchedulerWindowFactory : ISchedulerDialogHostFactory
    {
     ISchedulerDialogHost ISchedulerDialogHostFactory.CreateNew(ScheduleViewBase scheduleView, DialogType dialogType)
     {
      SchedulerWindow schedulerWindow = new SchedulerWindow
      {
       ResizeMode = Telerik.Windows.Controls.ResizeMode.NoResize,
       Content = new SchedulerDialog(),
       ScheduleView = scheduleView
      };
      
      // Instead of setting a theme, you could set properties and even styles here.
      StyleManager.SetThemeFromParent(schedulerWindow, scheduleView);
      
      return schedulerWindow;
     }
    }



    Greetings,

    Valeri Hristov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. DevCraft banner
  4. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 21 Jan 2011 Link to this post

    Sounds like this should work. I will try it. Thanks!
  5. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 24 May 2011 Link to this post

    Hi Valeri,

    This is exactly what we need to do: change the RadWindow properties of the RadScheduleView's Edit Appointment Dialogue. It is very helpful to see it done in code. Could you also provide a sample Silverlight project that uses this technique to change the properties of the EditAppointment dialogue? I know it's pain to put a sample together, but a sample solution would be extremely helpful to us.

    EDIT: I've been able to get this going in code behind such as :

    scheduleView.SchedulerDialogHostFactory = new MySchedulerWindowFactory();

    However my attempts to do this in XAML have all resulted in some frustratingly vague (I'm not blaming Telerik for that!---that's all MS) XAML parser messages so it would be great to see how that's done. However I do have it running so don't worry about the Silverlight sample solution if it's too time consuming.

    Cheers,
    Scott
  6. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 25 May 2011 Link to this post

    Hi Scott,

    Please, find attached the requested application. I just set the CanMove=false on all dialogs. If you want to customize just one, you could use the dialogType parameter of the CreateNew method.

    All the best,
    Valeri Hristov
    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
  7. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 25 May 2011 Link to this post

    Hi Valeri,

    Thanks for the fast reply--and thanks very much for the sample. I can see now the proper way to assign the DialogHostFactory in xaml. I have been able to change several SchedulerWindow properties. Is it possible to control the "modal-ness" of the EditAppointmentDialog? SchedulerWindow.IsModal looked promising, but it is read-only. We are hoping to be able to open multiple EditAppointmentDialogue windows at once.

    Thanks,
    Scott
  8. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 26 May 2011 Link to this post

    Hi Scott,

    Non-modal dialogs are not supported. Our dialogs put the corresponding appointment in edit mode and since you cannot have multiple appointments in edit mode you cannot have several dialogs open simultaneously. It is possible to create non modal dialogs if you replace all of the dialog logic in RadScheduleView - cancel the ShowDialog event and do everything by hand. But this is a lot of work and it is possible that you will hit other obstacles. We will consider adding code that will allow the developers to easily create non-modal windows in the future, but for now this mode is not officially supported.

    All the best,
    Valeri Hristov
    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
  9. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 26 May 2011 Link to this post

    Hi,

    I'm trying to compleately change the dialog cause we need much different look and functionality.
    I tried your example with creating my own SchedulerDialogHostFactory. I'm opening my own standard Silverlight ChildWindow here but get an exception when it opens.
    I guess I need to implement some functionality in it to make it work. (right now its empty).
    What code do I need?

    Regards,
    Håkan
  10. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 26 May 2011 Link to this post

    Hi Hakan,

    To replace the RadWindow with a ChildWindow you need to create a new class that is a descendant of ChildWindow and implements the ISchedulerDialogHost interface. Then you need to return instances of this class from the factory method.

    Greetings,
    Valeri Hristov
    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
  11. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 31 May 2011 Link to this post

    I have created a ChildWindow that implements
    ISchedulerDialogHost
    

    But when I double click an existing appointment I get an error that looks like this:

    "Unhandled Error in Silverlight Application \nCode: 4004    \nCategory: ManagedRuntimeError       \nMessage: System.Windows.Markup.XamlParseException:  [Line: 0 Position: 0]\r\n   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)\r\n   at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)\r\n   at System.Windows.DependencyObject.SetValue(DependencyProperty property, DependencyObject doh)\r\n   at System.Windows.FrameworkElement.set_Style(Style value)\r\n   at Telerik.Windows.Controls.ScheduleViewBase.CreateDialogHost(Style dialogStyle, DialogType type)\r\n   at Telerik.Windows.Controls.ScheduleViewBase.CreateAppointmentDialogViewModel(Occurrence occurrence, AppointmentViewMode viewMode)\r\n   at Telerik.Windows.Controls.ScheduleViewBase.OpenAppointmentDialog(Occurrence occurrence, AppointmentViewMode viewMode)\r\n   at Telerik.Windows.Controls.ScheduleViewBase.OpenEditDialog(Occurrence occurrence, Boolean isEditable)\r\n   at Telerik.Windows.Controls.ScheduleViewBase.EditWithDialog(IAppointment appointment)\r\n   at Telerik.Windows.Controls.ScheduleViewBase.EditWithDialog(IOccurrence occ)\r\n   at Telerik.Windows.Controls.ScheduleViewBase.OnEditAppointmentExecuted(Object sender, ExecutedRoutedEventArgs e)\r\n   at Telerik.Windows.Controls.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)\r\n   at Telerik.Windows.Controls.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)\r\n   at Telerik.Windows.Controls.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)\r\n   at Telerik.Windows.Controls.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)\r\n   at Telerik.Windows.Controls.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)\r\n   at Telerik.Windows.Controls.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)\r\n   at Telerik.Windows.RadRoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n   at Telerik.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RadRoutedEventArgs routedEventArgs)\r\n   at Telerik.Windows.RouteItem.InvokeHandler(RadRoutedEventArgs routedEventArgs)\r\n   at Telerik.Windows.EventRoute.InvokeHandlersImpl(Object source, RadRoutedEventArgs args, Boolean raisedAgain)\r\n   at Telerik.Windows.EventRoute.InvokeHandlers(Object source, RadRoutedEventArgs args)\r\n   at Telerik.Windows.RadRoutedEventHelper.RaiseEvent(DependencyObject element, RadRoutedEventArgs args)\r\n   at Telerik.Windows.DependencyObjectExtensions.RaiseEvent(DependencyObject element, RadRoutedEventArgs e)\r\n   at Telerik.Windows.Controls.RoutedCommand.ExecuteImpl(Object parameter, UIElement target)\r\n   at Telerik.Windows.Controls.RoutedCommand.Execute(Object parameter, UIElement target)\r\n   at Telerik.Windows.Controls.CommandManager.ExecuteCommand(RoutedCommand routedCommand, Object parameter, UIElement target, RoutedEventArgs inputEventArgs)\r\n   at Telerik.Windows.Controls.CommandManager.TranslateInput(UIElement targetElement, RoutedEventArgs args)\r\n   at Telerik.Windows.Controls.CommandManager.OnElementEvent(Object sender, RoutedEventArgs e)\r\n   at Telerik.Windows.Input.Mouse.RaiseMouseButtonEventImpl(DependencyObject element, RoutedEvent routedEvent, MouseButton button, MouseButtonState state, MouseButtonEventArgs e)\r\n   at Telerik.Windows.Input.Mouse.OnElementMouseLeftButtonUp(Object sender, MouseButtonEventArgs e)\r\n   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)\r\n   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)     \n"

    I still dont understand how to implement my own dialog with my own appointment type and viewmodel.

    Do you have any simple code example where you have extended the Appointment class and used a standard Silverlight ChildWindow as edit dialog.

    Regards,
    Håkan
  12. George
    Admin
    George avatar
    1332 posts

    Posted 06 Jun 2011 Link to this post

    Hi Håkan,

     

    We have an example that  uses custom appointments and ChildWindow for a custom appointment dialog. You can find the attached sample. 

    I hope this helps.


    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
  13. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 08 Jun 2011 Link to this post

    Hi Valeri & George,

    Thanks for posting the ScheduleView-CustomDialogHost sample solution. We have modified that solution in an attempt to do the following:

    • Create a non-modal EditAppointmentDialog supporting the viewing and/or editing of multiple Appointments at the same time.

    I've modified your sample such that CustomAppointmentDialogHost now derives from RadWindow instead of ChildWindow in an attempt to avoid the modal behaviour.

    Earlier in this thread, Valeri mentioned that "Non-modal dialogs are not supported. Our dialogs put the corresponding appointment in edit mode and since you cannot have multiple appointments in edit mode you cannot have several dialogs open simultaneously." Consistent with this statement, our attempt to open two Appointments at the same time succeded until we made a change to one of the Appointments and tried to save it. Viewing and Cancelling the two dialogue seem to work.

    When we attempt to edit multiple Appointments, the following unhandled exception is thrown:

    {System.NullReferenceException: Object reference not set to an instance of an object.
     
       at Telerik.Windows.Controls.ScheduleView.DateSpan..ctor(IDateSpan other)
       at Telerik.Windows.Controls.ScheduleView.Slot..ctor(IDateSpan other)
       at Telerik.Windows.Controls.ScheduleView.ReadOnlyBehavior.CanEditAppointment(IOccurrence occurrence)
       at Telerik.Windows.Controls.ScheduleView.ReadOnlyBehavior.CanSaveAppointment(IOccurrence occurrence)
       at Telerik.Windows.Controls.ScheduleViewBase.OnAppointmentEditConfirmed(Object sender, EventArgs e)
       at Telerik.Windows.Controls.SchedulerDialogViewModel.OnConfirmed(EventArgs eventArgs)
       at Telerik.Windows.Controls.SchedulerDialogViewModel.<OnConfirmCommand>b__0(SchedulerDialogViewModel vm)
       at Telerik.Windows.Controls.SchedulerDialogViewModel.DoWithViewModel[T](Object sender, Action`1 action)
       at Telerik.Windows.Controls.SchedulerDialogViewModel.OnConfirmCommand(Object sender, ExecutedRoutedEventArgs e)
       at Telerik.Windows.Controls.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
    ...

    EDIT: Questions:
    1. Can you explain in more detail why this is happening and why we cannot have multiple appointments in edit mode simultaneously? Unfortunately we really need to implement this multiple-view/edit behaviour in our application.
    2. How difficult (just a general, subjective characterisation) would it be to use our own View Model for the EditAppointmentDialogue?Where/at what point would be the best place to set the view's DataContext?

    I have a sample solution as a .zip file, but I am not able to attach it. Let me know if you want it and I'll eMail, etc.

    Cheers,
    Scott
  14. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 15 Jun 2011 Link to this post

    Valeri, George??

    Are you able to give me any feedback on the questions from my last post?

    Cheers,
    Scott
  15. George
    Admin
    George avatar
    1332 posts

    Posted 15 Jun 2011 Link to this post

    Hi Scott,


    Straight to your questions:

    1. We are using CollectionView in order to store the appointments, and this collection allows editing of only one item at the same time. We will look into this feature request in our further development, but this is not a in our major TODO list.
    2. We set the AppointmentDialogViewModel as a DataContext of the EditDialog window in the code and we don't support replacing this DataContext. If you have custom appointments, you could get the instance in edit state using the DataContext.Occurrence.Appointment. Could you please let us know why do you need to replace the DataContext ?


    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
  16. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 15 Jun 2011 Link to this post

    Hi George,

    Thanks for the information. I'll have to look further into the CollectionView to fully understand your answer to my Question 1, but that's fine. Regarding our need to change the DataContext for the EditAppointmentDialogue: we need to do this because we are using the EditAppointmentDialgue as a kind of "DetailView" on our Booking entities.  We are using our own Booking entities which implement Telerik's IAppointment interface so that they are useable by the RadScheduleView. We have added quite a few of our own fields to the EditAppointmentDialoge, and it's more efficient for us to bind directly to our BookingHomeViewModel as the EditAppointmentDialg's DataContext . We have done this by setting the the DataContext as follows:

    (Formatting this block as code made it more difficult to read with a lot of <br/> elements)

        internal class SchedulerWindowFactory : ISchedulerDialogHostFactory
        {
            ISchedulerDialogHost ISchedulerDialogHostFactory.CreateNew(ScheduleViewBase scheduleView, DialogType dialogType)
            {
                var dialogContent = new SchedulerDialog();
                dialogContent.HorizontalAlignment = HorizontalAlignment.Center;
                dialogContent.VerticalAlignment = VerticalAlignment.Center;
                dialogContent.HorizontalContentAlignment = HorizontalAlignment.Center;
                dialogContent.VerticalContentAlignment = VerticalAlignment.Center;
               
                // Set our own DataContext
                IBookingHomeViewModel bhvm = ApplicationGlobalService.Container.Resolve<IBookingHomeViewModel>();
                dialogContent.DataContext = bhvm;
                
                // Sets witdth to "Auto"
                dialogContent.SetValue(SchedulerDialog.WidthProperty,double.NaN);
               
                //Default size
                var dimensions = new Point(240, 320);
     
                switch (dialogType)
                {
                    case DialogType.ConfirmationDialog:
                    case DialogType.RecurrenceChoiceDialog:
                        dimensions.X = 240;
                        dimensions.Y = 140;
                        break;
                    default:
                        break;
                }
     
                dialogContent.MinWidth = dimensions.X;
                dialogContent.MinHeight = dimensions.Y;
     
                SchedulerWindow schedulerWindow = new SchedulerWindow
                {
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    VerticalContentAlignment = VerticalAlignment.Center,
     
                    ResizeMode = Telerik.Windows.Controls.ResizeMode.CanMinimize,
                    WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen,
                    ScheduleView = scheduleView,
                    Content = dialogContent,
                };
                return schedulerWindow;
            }
        }
    ------------------------------------------------
    Changing the DataContext broke some of the existing EditAppointmentDialogue functionality, but it has saved us heaps of time by not having to bind to "intermediary" (to our BookingHomeViewModel) static resources for many other fields.

    Can you forsee any problems with this appproach?

    Cheers,
    Scott
  17. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 23 Jun 2011 Link to this post

    Hello Scott,

    We're glad that you've managed to find a suitable way to set  a different DataContext to EditAppointmentDialog  - we don't see any problems with this approach.

    Best wishes,
    Yana
    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
  18. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 26 Jun 2011 Link to this post

    Hi Yana, George, Valeri, et al,

    We have been generally successful using our own view model on the EditAppointmentDialog with the exception of two issues:

    1. The dialog's <OK> and <Cancel> buttons are disabled
    2. The EditRecurrence Button does not work

    I see these buttons are implemented with Commands. What do I need to add to my ViewModel in order for these commands to work? I can keep a reference to your default ViewModel in our new ViewModel if needed. Are these meant to be  bound to ICommand properties on your default ViewModel?

    Thanks,
    Scott
  19. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 30 Jun 2011 Link to this post

    Hi Scott,

    We're preparing an example demonstrating the needed approach. I'll attach it here as soon as it's ready. Thank you for your patience.

    Best wishes,
    Yana
    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
  20. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 30 Jun 2011 Link to this post

    Hi Yana,

    That will be very helpful--thanks. We've had to modify our approach in order to continue forward. Your AppointmentDialogViewModel has some members we need, so intead of replacing that ViewModel with our own, we've made our ViewModel available for binding as a StaticResource while your ADVM remains the dialog's DataContext. It's solves some problems, but it's a bit awkward in some ways as well. The Blend designer doesn't like it much for one. It would be great to have a better undrestanding of how to use your ADVM.

    Cheers,
    Scott
  21. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 21 Jul 2011 Link to this post

    Hi Yana,

    Has there been any progress with the sample project you mentioned?

    We are having some difficulty with our EditAppointmentDialog, largely because we have significantly modified it, and we need to bind to custom ViewModel properties that are not available on the default AppointmentDialogViewModel; however we also need to bind to AppointmentDialogViewModel's properties for many things including the <Save> and <Cancel> buttons plus the EditRecurrence and EditParentBooking buttons.

    We are using custom Appointment classes called "Bookings" that implement IAppointment. We need to bind to some calculated values that are not appropriate to add to the Booking class and really belong on the ViewModel.

    What is your recommended approach for binding to a user-defined ViewModel in the EditAppointmentDialog?

    Currently we're binding to our own "BookingzHomeViewModel" via a StaticReference to our viewModel and the Source binding property:

    <ViewModels:BookingHomeViewModel x:Key="bhvm" />
    <TelerikInput:RadComboBox x:Name="SubscriptionRadComboBox"
           Grid.Row="1"
           Grid.Column="1"
           IsEnabled="{Binding IsReadOnly, Converter={StaticResource InvertedBooleanConverter}}"
            Visibility="{Binding Path=Ocurrence.Appointment.IsMultipleSubscription, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}"
           ItemsSource="{Binding Path=Current.SubscriptionComboItemSource, Source={StaticResource bhvm}}"
              SelectedItem="{Binding Path=Ocurrence.Appointment.Subscription, Mode=TwoWay}"
           />

    In the code snippet above, we are displaying a comboBox with a list of "Subscriptions". Our BookingHomeViewModel is required to provide the RadComboBox's ItemSource (collection of Subscription objects).

    This works, but it is somewhat awkward and seems to have some odd and random side effects. For example, The RadComboBox seems to set Ocurrence.Appointment.Subscription to null each time (using the Telerik 2011 Q2 controls). Replacing the RadComboBox with a stock Silverlight ComboBox displays the value of Ocurrence.Appointment.Subscription as expected. We used a "debug converter" on the binding to witness this. Also there appear to be some timing issues where data in our BookingHomeViewModel are not available in time for the binding--just generally random problems.

    So our question is:

    In the AppointmentEditDialog, what is your recommended approach for binding to custom properties such as SubscriptionComboItemsSource above while retaining the ability to call the EditRecurrence dialoge and enable <Save> and <Close> buttons (properties on your AppointmentDialogViewModel)?

    A sample project demonstrating your recommended approach would be hugely helpful.

    Thanks for your help,
    Scott




  22. Simon
    Simon avatar
    47 posts
    Member since:
    May 2008

    Posted 27 Jul 2011 Link to this post

    I would also like to see this as we're having similar problems.
    Thanks
    Simon
  23. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 27 Jul 2011 Link to this post

    Hello,

    Please try the approach demonstrated in this forum thread - the idea is that the custom ViewModel holds a reference to the default AppointmentDialogViewModel. A sample project is attached to the thread, please examine it and let us know whether it helps in you case.

    Kind regards,
    Yana
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  24. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 27 Jul 2011 Link to this post

    Thanks very much Yana,

    That sounds very promising. We will have a look at the ScheduleView-SL-5.zip sample.

    Cheers,
    Scott

Back to Top
DevCraft banner