Welcome to the Xceed Community | Help
Community Search  
More Search Options

Datepickerr changed

Sort Posts: Previous Next
  •  02-24-2009, 7:05 AM Post no. 18832

    Datepickerr changed

    Hi,

    I'm a VB newbie and wondered how does one detect that the date has changed when a new selection is made on the calender.

    Thanks in advance 

    Filed under:
  •  02-24-2009, 7:24 AM Post no. 18836 in reply to 18832

    Re: Datepickerr changed

    In C# I have subsribed to the DatePicker.SelecteddateProperty changed as follows:

    DependencyPropertyDescriptor selectedDateChangedDescriptor =

    DependencyPropertyDescriptor.FromProperty(DatePicker.SelectedDateProperty, typeof(DatePicker));

    selectedDateChangedDescriptor.AddValueChanged(ctlSessionStartDate, new EventHandler(DatePicker_SelectionChanged));

     

    Sorry not VB, but that should point you in the right direction.

  •  02-26-2009, 12:58 PM Post no. 18936 in reply to 18832

    Re: Datepickerr changed

    For info the following works:

        Protected Overrides Sub OnInitialized(ByVal e As EventArgs)

            MyBase.OnInitialized(e)

            Dim dpSourceDescriptor As DependencyPropertyDescriptor = DependencyPropertyDescriptor.FromProperty(Xceed.Wpf.Controls.DatePicker.SelectedDateProperty, GetType(Xceed.Wpf.Controls.DatePicker))

            dpSourceDescriptor.AddValueChanged(Me.xcd_Date, New EventHandler(AddressOf OnSelectedDateChanged))

        End Sub

        Protected Sub OnSelectedDateChanged(ByVal sender As Object, ByVal args As EventArgs)

            TextBox1.Text = xcd_Date.SelectedDate

            MsgBox("Changed")

        End Sub

     

  •  05-05-2009, 9:06 PM Post no. 20743 in reply to 18936

    Re: Datepickerr changed

    the easiest wayto get notification is just to bind to the SelectedDate property like so

     

    <xcdg:DatePicker
             SelectedDate="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MyUserControl}}, Mode=TwoWay, Path=SourceDate, UpdateSourceTrigger=PropertyChanged}"/>

     

    in this example the date picker is in a UserControl called MyUserControl (in an xml name space called local) and i am binding the SourceDate field on my user control to the date picker control. Im using a TwoWay binding so every time the date picker has a new selection made i hear about it and if i change the SourceDate property in code the date picker will change its selected date as well.      

     

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.