Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: DateTimePicker- Updating and displaying value from Code

$
0
0
Hello-

I'm working with the DateTimePicker control. So far it's doing most of what I want, but I can't seem to get it to display a value that was previously entered. Essentially, I want to be able to open a form to set a day, click okay on that form, and then be able to open a new instance of that form to edit the day entered. All of the back end, data code works. I can set and update a day properly. But, I want to be able to see the old date that was entered the user returns to the form to change something.

My form has two DateTimePickers, start and end day. Here is the XAML for them. It's different for troubleshooting, neither works. Once one does I'll use that for both, of course:
<xctk:DateTimePicker Name="dtp_StartDTPicker"
                Value="{Binding Path=StartDT, 
                    UpdateSourceTrigger=PropertyChanged, 
                    Mode=TwoWay, 
                    ValidatesOnExceptions=True, 
                    NotifyOnValidationError=True}"
                Text="{Binding Path=StartString, 
                    UpdateSourceTrigger=PropertyChanged, 
                    Mode=TwoWay, 
                    ValidatesOnExceptions=True, 
                    NotifyOnValidationError=True}"/>

<xctk:DateTimePicker Name="dtp_EndDTPicker"
        Value="{Binding Path=EndDT}"
        Text="{Binding Path=EndString}"/>
Also, here's my C# code for the Window, at least the relevant parts. You can open the window in two ways, blank, with no parameter, or with a data structure (A Conflict, in this case, but that's a class I made and not relevant to this issue) to edit that structure.
public ConflictWindow()
        {
            InitializeComponent();
        }


        public ConflictWindow(Conflict a_conflict)
        {
            InitializeComponent();

            m_conflict = a_conflict;
            txtbx_Reason.Text = m_conflict.Reason;

            dtp_StartDTPicker.Value = m_conflict.StartDate;
            dtp_EndDTPicker.Value = m_conflict.EndDate;

            StartString = m_conflict.StartDate.ToString();
            dtp_StartDTPicker.Text = StartString;

            EndString = m_conflict.EndDate.ToString();
            dtp_EndDTPicker.Text = EndString;
        }
I think a lot of my code is doing the same thing the XAML does, but nothing seems to work. Can someone help me out?

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>