protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); InitTask(); OrderFields(); SetRichElementsState(); CategoryPresenter.DataContext = TaskCategory.GetById(task.CategoryId); this.DataContext = task; }
private void CategoriesList_SelectionChanged(object sender, SelectionChangedEventArgs e) { TaskCategory selectedCategory = CategoriesList.SelectedItem as TaskCategory; if (selectedCategory != null) { this.SetValue(RadTransitionControl.TransitionProperty, new RadTileTransition()); this.SetValue(RadTileAnimation.ContainerToAnimateProperty, CategoriesList); NavigationService.Navigate(new Uri("/Views/TasksByCategory.xaml?CategoryId=" + selectedCategory.Id, UriKind.Relative)); } }
// This is added in order to be able to fastly populate the database and to see the application running with a real data. private void InitApplicationForFirstTimeUse() { // this is the first time the app is run on device // populate the deatabase with the predefined categories TaskCategory.PopulateDataBase(); MessageBoxResult result = MessageBox.Show("This is the first time you open the application. Do you want to generate a test data?", "One time message", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { GenerateTestData(); } }
// For each category we want to display different fields. The rest of the fields remain in the advanced panel. private void OrderFields() { string[] categoryFields = TaskCategory.GetById(task.CategoryId).DefaultFields; if (categoryFields == null) { return; } for (int i = 0; i < categoryFields.Length; i++) { UIElement field = this.FindName(categoryFields[i]) as UIElement; if (AdvancedFieldsContainer.Children.Contains(field)) // in case of thombstoning { AdvancedFieldsContainer.Children.Remove(field); CategoryFieldsContainer.Children.Add(field); } } CategoryFieldsContainer.DataContext = task; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { int categoryId = (int)value; return(TaskCategory.GetById(categoryId).IconUri); }