Hi,
I am facing problem of accessing control which is there inside the outlookgroup.
I have 2 group
1, Date range
2. Measurements
Inside the date range I have 2 datetime control.
But when the page is initialized I set the value as follows.
public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); this.Loaded += new RoutedEventHandler(MainPage_Loaded); this.fromDatePicker.SelectedDate = DateTime.UtcNow; this.toDatePicker.SelectedDate = DateTime.UtcNow; }
but it is coming as object reference error. Even I tried with other controls and event as well.
For a test purpose I put a radio button and set the value IsChecked=True during design. On a button click I tried setting the checked state to false. Still I get the object reference error.
Any propertied of the XamOutlookbar I need to set inorder to access the control???
Please help
Thanks
-Sajin
Thanks Marinni...It works well now...
:)
Hi Sajin,This solution does not work in Loaded event-handler.Move the code that initializes member variables to the LayoutUpdated event-handlerRegards,Marin
I am still facing the problem, As you suggested I am accessing the control by "FindByName"
RadioButton a = this.FindName("rdYTD") as RadioButton; a.IsChecked = true;
If I put this code in Page load, then the page in not loading even...the progress indicator just spins..thats it..
Could you please let me know what causing the problem.
This behavior is because of how the XamOutlookBar is designed to work. Whenever you have any elements in OutlookBarGroup and you set it's Name or x:Name property, the variable which is automatically generated to reference this element has null value at runtime.
This is also a limitation in other controls which have items in them.
Instead you could use this.FindName("fromDatePicker") as DatePicker .
HTH,