I am using SetIndicatorValueFromAddonWindow as a guide (https://ninjatrader.com/support/foru...686#post492686) that NinjaTrader_ChelseaB created but I can not get a DatePicker to work properly.
Issues:
1) The Date does not show in the DatePicker either on Load or after SelectionChanged
2) Error in the SelectionChanged event
Here is the code from the latest attempt:
private DatePicker enterDate;
private DependencyObject LoadXaml()
{
DatePicker enterDate = (LogicalTreeHelper.FindLogicalNode(page, "dp_EnterDate") as DatePicker) ;
enterDate.SelectedDate = TargetIndicator.EnterDate;
// EnterDate from Indicaor is set to Datetime.Now
NinjaTrader.Code.Output.Process(string.Format(" TargetIndicator.EnterDate {0}", TargetIndicator.EnterDate ), PrintTo.OutputTab1);
NinjaTrader.Code.Output.Process(string.Format(" enterDate.Text {0}", enterDate.Text ), PrintTo.OutputTab1);
// These 2 Outputs above print the correct values
if (enterDate != null)
enterDate.SelectedDateChanged += EnterDateDropDown_SelectionChanged;
}
private void EnterDateDropDown_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
NinjaTrader.Code.Output.Process("EnterDateDropDown_SelectionChanged ", PrintTo.OutputTab1);
NinjaTrader.Code.Output.Process(string.Format(" sender {0}",sender) , PrintTo.OutputTab1);
// Prints: "sender 4/10/2018 12:00:00 AM"
NinjaTrader.Code.Output.Process(string.Format(" e {0}",e) , PrintTo.OutputTab1);
// Prints: "e System.Windows.Controls.CalendarSelectionChangedEventArgs"
// This Output throws Error
// "Unhandled exception: Object reference not set to an instance of an object"
NinjaTrader.Code.Output.Process(string.Format(" Selected Date {0}",enterDate.SelectedDate) , PrintTo.OutputTab1);
}
Comment