当前位置: 首页>>代码示例>>C#>>正文


C# ListPicker.SetValue方法代码示例

本文整理汇总了C#中Microsoft.Phone.Controls.ListPicker.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ListPicker.SetValue方法的具体用法?C# ListPicker.SetValue怎么用?C# ListPicker.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Phone.Controls.ListPicker的用法示例。


在下文中一共展示了ListPicker.SetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainPage

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            // Add the quick toggles defined in Tweaks
            foreach (TweakCategory cat in Tweaks.Tweaks.Categories)
            {
                if (cat.Tweaks.Count > 0)
                {
                    addCategory(cat.Title);
                    foreach (Tweak t in cat.Tweaks)
                    {
                        if (!Versions.IsNewerOrCurrentOS(t.MinOSVersion))
                        {
                            continue;
                        }
                        if (!Versions.IsOlderOS(t.MaxOSVersion))
                        {
                            continue;
                        }
                        if (t is ToggleTweak)
                        {
                            var tweak = (ToggleTweak)t;
                            ToggleSwitch control = new ToggleSwitch();
                            control.Tag = tweak;
                            control.Header = tweak.Title;
                            if (tweak.Description != "")
                                control.Content = tweak.Description;

                            control.FontSize = 22;

                            //get valuelolo
                            if (tweak.KeyType == TweakType.DWORD)
                            {
                                uint val = Registry.ReadDWORD(tweak.Hive, tweak.KeyName, tweak.ValueName);
                                control.IsChecked = (val == (int)tweak.OnValue);
            #if DEBUG
                                System.Diagnostics.Debug.WriteLine(tweak.Title + " = " + val);
            #endif
                            }
                            else if (tweak.KeyType == TweakType.String)
                            {
                                string val = Registry.ReadString(tweak.Hive, tweak.KeyName, tweak.ValueName);
                                control.IsChecked = (val == (string)tweak.OnValue);
            #if DEBUG
                                System.Diagnostics.Debug.WriteLine(tweak.Title + " = " + val);
            #endif
                            }

                            control.Checked += new EventHandler<RoutedEventArgs>(control_Checked);
                            control.Unchecked += new EventHandler<RoutedEventArgs>(control_Checked);

                            controlsPanel.Children.Add(control);
                        }
                        else if (t is SelectorTweak)
                        {
                            var tweak = (SelectorTweak)t;
                            ListPicker lp = new ListPicker();
                            lp.Tag = tweak;
                            lp.Header = tweak.Title;
                            lp.ItemsSource = tweak.Options;
                            lp.SetValue(ListPicker.ItemCountThresholdProperty, 10);
                            if (tweak.KeyType == TweakType.DWORD)
                            {
                                uint val = Registry.ReadDWORD(tweak.Hive, tweak.KeyName, tweak.ValueName);
                                foreach (var opt in tweak.Options)
                                {
                                    if ((int)opt.Value == val)
                                    {
                                        lp.SelectedItem = opt;
                                        break;
                                    }
                                }
            #if DEBUG
                                System.Diagnostics.Debug.WriteLine(tweak.Title + " = " + val);
            #endif
                            }
                            else if (tweak.KeyType == TweakType.String)
                            {
                                string val = Registry.ReadString(tweak.Hive, tweak.KeyName, tweak.ValueName);
                                foreach (var opt in tweak.Options)
                                {
                                    if ((string)opt.Value == val)
                                    {
                                        lp.SelectedItem = opt;
                                        break;
                                    }
                                }
            #if DEBUG
                                System.Diagnostics.Debug.WriteLine(tweak.Title + " = " + val);
            #endif
                            }
                            lp.SelectionChanged += new SelectionChangedEventHandler(lp_SelectionChanged);
                            lp.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(lp_Tap);
                            controlsPanel.Children.Add(lp);
                        }
                        else if (t is SliderTweak)
                        {
                            var tweak = (SliderTweak)t;
                            uint val = Registry.ReadDWORD(tweak.Hive, tweak.KeyName, tweak.ValueName);
//.........这里部分代码省略.........
开发者ID:jessenic,项目名称:wph-tweaks,代码行数:101,代码来源:MainPage.xaml.cs

示例2: MainPage

        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Check for root
            if (WP7RootToolsSDK.Environment.HasRootAccess())
            {
                // Add the quick toggles defined in Tweaks
                foreach (Tweak tweak in Tweaks.tweaks)
                {
                    if (tweak.type == Tweak.controlType.toggle)
                    {
                        ToggleSwitch control = new ToggleSwitch();

                        control.Header = tweak.title;
                        if (tweak.description != "")
                            control.Content = tweak.description;

                        control.FontSize = 22;

                        //get valuelolo
                        if (tweak.keyType == Tweak.tweakType.dword)
                        {
                            var val = 0;
                            try
                            {
                                val = (int)WP7RootToolsSDK.Registry.GetDWordValue(tweak.getHyve(), tweak.getKeyName(), tweak.getValueName());
                            }
                            catch
                            {

                            }
                            control.IsChecked = (val == tweak.onValue);
                        }
                        if (tweak.keyType == Tweak.tweakType.str)
                        {
                            var val = "";
                            try
                            {
                                val = WP7RootToolsSDK.Registry.GetStringValue(tweak.getHyve(), tweak.getKeyName(), tweak.getValueName());
                            }
                            catch
                            {
                            }
                            control.IsChecked = (val == tweak.strOnValue);
                        }

                        control.Checked += new EventHandler<RoutedEventArgs>(control_Checked);
                        control.Unchecked += new EventHandler<RoutedEventArgs>(control_Checked);

                        controlsPanel.Children.Add(control);
                    }
                    if (tweak.type == Tweak.controlType.selector)
                    {
                        ListPicker lp = new ListPicker();
                        lp.Header = tweak.title;
                        lp.ItemsSource = tweak.options;
                        lp.SetValue(ListPicker.ItemCountThresholdProperty, 10);
                        lp.SelectionChanged += new SelectionChangedEventHandler(lp_SelectionChanged);
                        lp.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(lp_Tap);
                        controlsPanel.Children.Add(lp);
                    }
                    if (tweak.type == Tweak.controlType.title)
                    {
                        addCategory(tweak.title);
                    }
                }
            }
            else
            {
                LayoutRoot.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
开发者ID:windowsphonehacker,项目名称:wph-tweaks,代码行数:74,代码来源:MainPage.xaml.cs


注:本文中的Microsoft.Phone.Controls.ListPicker.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。