本文整理汇总了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);
//.........这里部分代码省略.........
示例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;
}
}