コード例 #1
0
        private void CheckBoxItem(Person person)
        {
            //var count = lbPerson.Items.Count;
            //count = lbPerson.ItemContainerGenerator.Items.Count;
            //for (int i = 0; i < count; i++)
            //{
            //    var item = lbPerson.Items[i];
            //    System.Diagnostics.Debug.WriteLine(item.ToString());
            var boxItem = lbPerson.ItemContainerGenerator.ContainerFromItem(person);

            System.Diagnostics.Debug.WriteLine(boxItem.ToString());
            var textblock = VisualTreeHelperExtensions.FindChild <TextBlock>(boxItem);

            if (textblock != null)
            {
                var context = textblock.ContextMenu;
                System.Diagnostics.Debug.WriteLine(context.Items.Count);
                var m2 = context.Items[1] as MenuItem;
                m2.IsCheckable = true;
                m2.IsChecked   = true;
            }
            //}
        }
コード例 #2
0
        private void DXWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            try
            {
                //System.Windows.Data.CollectionViewSource myCollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["serversViewSource"];
                //// Things work if this line is present.  Testing to see if it works without 6/13/2012
                //// Yup, still works.  Don't need this line as it is done in the XAML.
                //myCollectionViewSource.Source = EyeOnLife.Common.ApplicationDataSet.Servers;

                ((CollectionViewSource)this.Resources["serversViewSource"]).Source = Common.ApplicationDataSet.Servers;

                ((CollectionViewSource)this.Resources["adDomains"]).Source     = Common.ApplicationDataSet.LKUP_ADDomains;
                ((CollectionViewSource)this.Resources["environments"]).Source  = Common.ApplicationDataSet.LKUP_Environments;
                ((CollectionViewSource)this.Resources["securityZones"]).Source = Common.ApplicationDataSet.LKUP_SecurityZones;

                // This line changes the Source of the serversInstancesViewSource.

                ((CollectionViewSource)this.Resources["instancesViewSource"]).Source = Common.ApplicationDataSet.Instances;

                // Update the views.  First ensure a row is selected.

                tableView.FocusedRowHandle = 1;

                //serversGridControl.GroupBy("SecurityZone");

                //var ckDisplayEnvironmentColumns = DisplayOptions.VisualTreeHelperExtensions.FindAncestor<CheckBox>(cc_DisplayOptions_Instances);

                //var ckDisplayEnvironmentColumns = cc_DisplayOptions_Instances.FindName("ckDisplayEnvironmentColumns");

                var ckDisplayEnvironmentColumns = VisualTreeHelperExtensions.FindChild <CheckBox>(cc_DisplayOptions2, "ckDisplayEnvironmentColumns");
                ((CheckBox)ckDisplayEnvironmentColumns).IsChecked = true;

                //var ckDisplayOperatingSystemColumns = DisplayOptions.VisualTreeHelperExtensions.FindAncestor<CheckBox>(cc_DisplayOptions_Instances);
                var ckDisplayOperatingSystemColumns = VisualTreeHelperExtensions.FindChild <CheckBox>(cc_DisplayOptions2, "ckDisplayOperatingSystemColumns");
                ((CheckBox)ckDisplayOperatingSystemColumns).IsChecked = false;

                ViewMode.DisplayOptionsVisibility(cc_DisplayOptions2);
                ViewMode.DisplayOptionsVisibility(cc_DisplayOptions3);
                ViewMode.DisplayOptionsVisibility(cc_DisplayOptions4);
                ViewMode.DisplayOptionsVisibility(cc_DisplayOptions5);
                ViewMode.DisplayOptionsVisibility(cc_DisplayOptions6);
                ViewMode.DisplayOptionsVisibility(cc_DisplayOptions7);
                ViewMode.DisplayOptionsVisibility(cc_DisplayOptions8);
                ViewMode.DisplayOptionsVisibility(cc_DisplayOptions9);
                ViewMode.DisplayOptionsVisibility(cc_DisplayOptions10);

                ViewMode.SnapShotDetailsVisibility(lc_SnapShotDetails1);
                ViewMode.SnapShotDetailsVisibility(lc_SnapShotDetails2);
                ViewMode.SnapShotDetailsVisibility(lc_SnapShotDetails3);
                ViewMode.SnapShotDetailsVisibility(lc_SnapShotDetails4);
                ViewMode.SnapShotDetailsVisibility(lc_SnapShotDetails5);
                ViewMode.SnapShotDetailsVisibility(lc_SnapShotDetails6);
                ViewMode.SnapShotDetailsVisibility(lc_SnapShotDetails7);
                ViewMode.SnapShotDetailsVisibility(lc_SnapShotDetails8);
                ViewMode.SnapShotDetailsVisibility(lc_SnapShotDetails9);
                ViewMode.SnapShotDetailsVisibility(lc_SnapShotDetails10);

                ViewMode.AutoHideGroupVisibility(ahg_Left);
                ViewMode.AutoHideGroupVisibility(ahg_Top);
                ViewMode.AutoHideGroupVisibility(ahg_Right);
                ViewMode.AutoHideGroupVisibility(ahg_Bottom);

                //if (Common.UserMode == Common.UserModes.Basic)
                //{
                //    var adminOptions = VisualTreeHelperExtensions.FindChild<WrapPanel>(cc_DisplayOptions_Instances, "AdminOptions");
                //    ((WrapPanel)adminOptions).Visibility = System.Windows.Visibility.Hidden;
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }