예제 #1
0
        private async void SortDownSceneCmd_Click_1(object sender, RoutedEventArgs e)
        {
            var sceneCommand = SceneCmdsGrid.SelectedItem as SceneStoredCommand;

            if (sceneCommand == null)
            {
                return;
            }

            var scenecmdWeAreReplacing = sceneCommand.Scene.Commands.FirstOrDefault(s => s.SortOrder == sceneCommand.SortOrder + 1);

            if (scenecmdWeAreReplacing != null)
            {
                scenecmdWeAreReplacing.SortOrder--;
            }

            sceneCommand.SortOrder++;

            SortSceneCmDsGridBySortOrder();
            await SaveSceneCmdAsync();

            SortSceneCmDsGridBySortOrder();

            SceneCmdsGrid.SelectedItem = sceneCommand;
            SceneCmdsGrid.Focus();
        }
예제 #2
0
        private void SortSceneCmDsGridBySortOrder()
        {
            SceneCmdsGrid.CancelEdit();

            var dataView = CollectionViewSource.GetDefaultView(SceneCmdsGrid.ItemsSource);

            if (dataView == null)
            {
                return;
            }
            //clear the existing sort order
            dataView.SortDescriptions.Clear();
            //create a new sort order for the sorting that is done lastly
            dataView.SortDescriptions.Add(new SortDescription("SortOrder", ListSortDirection.Ascending));
            //refresh the view which in turn refresh the grid
            dataView.Refresh();
        }