本文整理汇总了C#中ListBox.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.SetValue方法的具体用法?C# ListBox.SetValue怎么用?C# ListBox.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListBox
的用法示例。
在下文中一共展示了ListBox.SetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestWPListBoxFBinding
public void TestWPListBoxFBinding()
{
var list = CreateSampleGroup();
var listbox = new ListBox();
listbox.SetValue(ElementBinder.BinderProperty , list.Binder );
list.SelectionMode = SelectionMode.Multiple;
list.SelectedIndex = 0;
Assert.AreEqual(listbox.Items.Count, 3);
Assert.AreEqual(list.SelectionMode, listbox.SelectionMode);
Assert.AreEqual(list.SelectedItem, listbox.SelectedItem);
listbox.SelectedIndex = 1;
Assert.AreEqual(list.SelectedIndex, listbox.SelectedIndex);
Assert.AreEqual(list.SelectedItem, listbox.SelectedItem);
var list2 = CreateSampleGroupInt();
listbox.SetValue(ElementBinder.BinderProperty, list2.Binder );
Assert.AreEqual(listbox.Items.Count, 4);
list2.SelectedIndex = 0;
Assert.AreEqual(list2.SelectedItem, listbox.SelectedItem);
Assert.AreEqual(list2.SelectedItem, 1);
Assert.IsNotNull(list2.SelectedItems);
}
示例2: NOPH_FreemapMainScreen_showMiniMenu
public static void NOPH_FreemapMainScreen_showMiniMenu(int __screen)
{
//mre.Reset();
FreeMapMainScreen screen = (FreeMapMainScreen)CRunTime.objectRepository[__screen];
System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
{
ListBox miniMenu = new ListBox();
miniMenu.SetValue(Canvas.LeftProperty, (double)150);
miniMenu.SetValue(Canvas.TopProperty, (double)300);
miniMenu.BorderBrush = new SolidColorBrush(Colors.White);
miniMenu.Foreground = new SolidColorBrush(Colors.White);
miniMenu.Background = new SolidColorBrush(Colors.Black);
miniMenu.FontSize = 40;
foreach (WazeMenuItem menuItem in miniMenuItems)
{
miniMenu.Items.Add(menuItem);
}
WazeMenuItem meOnMapL2V = new WazeMenuItem(NBidi.NBidi.LogicalToVisual(FreeMapMainScreen.MeOnMapItem.text),
FreeMapMainScreen.MeOnMapItem.ordinal,
FreeMapMainScreen.MeOnMapItem.priority,
FreeMapMainScreen.MeOnMapItem.wrapper_callback,
FreeMapMainScreen.MeOnMapItem.callback);
miniMenu.Items.Add(meOnMapL2V);
miniMenu.SelectionChanged += delegate(object sender, SelectionChangedEventArgs e)
{
ListBox lb = (ListBox)sender;
WazeMenuItem selectedItem = (WazeMenuItem)lb.SelectedItem;
screen.LayoutRoot.Children.Remove(miniMenu);
miniMenu = null;
miniMenuItems.Clear();
selectedItem.CallCallback();
};
screen.LayoutRoot.Children.Add(miniMenu);
//mre.Set();
});
//mre.WaitOne();
//
// screen.showMiniMenu();
}
示例3: NOPH_FreemapMainScreen_showMiniMenu
public static void NOPH_FreemapMainScreen_showMiniMenu(int __screen)
{
//mre.Reset();
System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
{
// Add Me on map as the last menu:
WazeMenuItem meOnMapL2V = new WazeMenuItem(LanguageResources.Instance.Translate("Cancel"),
GamePage.MeOnMapItem.ordinal,
GamePage.MeOnMapItem.priority,
GamePage.MeOnMapItem.wrapper_callback,
GamePage.MeOnMapItem.callback);
miniMenuItems.Add(meOnMapL2V);
GamePage mainScreen = (GamePage)GamePage.get();
if ((miniMenuItems.Count == 8) && (miniMenuItems[0].text == LanguageResources.Instance.Translate("Police"))) // Report type menu
{
mainScreen.NavigationService.Navigate<ReportPage>(miniMenuItems);
miniMenuItems = new List<WazeMenuItem>();
Syscalls.MiniMenuIsOn = false;
}
else if ((miniMenuItems.Count == 3) && (miniMenuItems[0].text == LanguageResources.Instance.Translate("My direction"))) // Direction menu
{
mainScreen.NavigationService.Navigate<ChooseDirectionPage>(miniMenuItems);
miniMenuItems = new List<WazeMenuItem>();
Syscalls.MiniMenuIsOn = false;
}
else // Other menu
{
ListBox miniMenu = new ListBox();
miniMenu.FlowDirection = FlowDirection.RightToLeft;
miniMenu.SetValue(Canvas.LeftProperty, (double)150);
miniMenu.SetValue(Canvas.TopProperty, (double)300);
miniMenu.BorderBrush = new SolidColorBrush(Colors.White);
miniMenu.Foreground = new SolidColorBrush(Colors.White);
miniMenu.Background = new SolidColorBrush(Colors.Black);
miniMenu.FontSize = 40;
// Build the menu items to display:
foreach (WazeMenuItem menuItem in miniMenuItems)
{
miniMenu.Items.Add(menuItem);
}
// Handle user choice:
miniMenu.SelectionChanged += delegate(object sender, SelectionChangedEventArgs e)
{
if (GamePage.get().GetPopupPanel() != null)
{
ListBox lb = (ListBox)sender;
WazeMenuItem selectedItem = (WazeMenuItem)lb.SelectedItem;
GamePage.get().GetPopupPanel().Children.Remove(miniMenu);
miniMenu = null;
// Clear the menu
miniMenuItems = new List<WazeMenuItem>();
//miniMenuItems.Clear();
MiniMenuIsOn = false;
// Fire the user selection:
selectedItem.CallCallback();
}
};
var popupPanel = GamePage.get().GetPopupPanel();
if (popupPanel != null)
{
popupPanel.Children.Add(miniMenu);
}
}
//mre.Set();
});
//mre.WaitOne();
//screen.showMiniMenu();
}