本文整理汇总了C#中System.Windows.Controls.ListBox.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.SetValue方法的具体用法?C# ListBox.SetValue怎么用?C# ListBox.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ListBox
的用法示例。
在下文中一共展示了ListBox.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetAutoScroll
public static void SetAutoScroll(ListBox instance, bool value)
{
var oldHandler = (AutoScrollHandler)instance.GetValue(AutoScrollHandlerProperty);
if (oldHandler != null)
{
oldHandler.Dispose();
instance.SetValue(AutoScrollHandlerProperty, null);
}
instance.SetValue(AutoScrollProperty, value);
if (value)
instance.SetValue(AutoScrollHandlerProperty, new AutoScrollHandler(instance));
}
示例2: SetSelectedItemsBinding
public static void SetSelectedItemsBinding(ListBox element, bool value)
{
element.SetValue(SelectedItemsProperty, value);
if (value)
{
element.SelectionChanged += (sender, args) =>
{
var x = element.SelectedItems;
};
}
}
示例3: GetOrCreateBehavior
private static ListSelectCommandBehavior GetOrCreateBehavior(ListBox selector)
{
var behavior = selector.GetValue(SelectCommandBehaviorProperty) as ListSelectCommandBehavior;
if (behavior == null)
{
behavior = new ListSelectCommandBehavior(selector);
selector.SetValue(SelectCommandBehaviorProperty, behavior);
}
return behavior;
}
示例4: GetOrCreateBehavior
private static SelectedItemsBehavior GetOrCreateBehavior(ListBox target, IList list)
{
var behavior = target.GetValue(SelectedItemsBehaviorProperty) as SelectedItemsBehavior;
if (behavior == null)
{
behavior = new SelectedItemsBehavior(target, list);
target.SetValue(SelectedItemsBehaviorProperty, behavior);
}
return behavior;
}
示例5: SetHasBindableSelectedItems
public static void SetHasBindableSelectedItems(ListBox source, bool value)
{
SelectionChangedHandler Handler = (SelectionChangedHandler)source.GetValue(SelectionChangedHandlerProperty);
if (value && Handler == null)
{
Handler = new SelectionChangedHandler(source);
source.SetValue(SelectionChangedHandlerProperty, Handler);
}
else if (!value && Handler != null)
{ source.ClearValue(SelectionChangedHandlerProperty); }
}
示例6: GetOrCreateBehavior
private static ListBoxSelectionChangedCommandBehavior GetOrCreateBehavior(ListBox ListBox)
{
ListBoxSelectionChangedCommandBehavior behavior =
ListBox.GetValue(SelectCommandBehaviorProperty) as ListBoxSelectionChangedCommandBehavior;
if (behavior == null)
{
behavior = new ListBoxSelectionChangedCommandBehavior(ListBox);
ListBox.SetValue(SelectCommandBehaviorProperty, behavior);
}
return behavior;
}
示例7: ListBox
public void ListBox(ListBox control)
{
// Setup initial conditions.
control.Width = 300;
control.Height = 200;
// Populate listbox with random data.
var list = new List<string>();
for (int i = 1; i <= 200; i++)
{
list.Add(string.Format("{0} - {1}", i, RandomData.LoremIpsum(1,3)));
}
control.ItemsSource = list;
// Apply the behavior.
control.SetValue(Behaviors.ListBoxMouseWheelScrollerProperty, new ListBoxMouseWheelScroller());
}
示例8: SetItems
public static void SetItems(ListBox listBox, IList list)
{
listBox.SetValue(ItemsProperty, list);
}
示例9: SetCommandParameter
public static void SetCommandParameter(ListBox ListBox, object parameter)
{
ListBox.SetValue(CommandParameterProperty, parameter);
}
示例10: SetListBoxMouseWheelScroller
public static void SetListBoxMouseWheelScroller(ListBox element, ListBoxMouseWheelScroller value) { element.SetValue(ListBoxMouseWheelScrollerProperty, value); }
示例11: cnvPaint_Drop
void cnvPaint_Drop(object sender, DragEventArgs e)
{
try
{
if (e.Data.GetData(typeof(Button)) != null)
{
if (((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Name.ToString() == "cnvControls")
{
Point p = e.GetPosition((IInputElement)cnvPaint);
Button btn = new Button();
btn.Height = 25;
btn.Width = 100;
btn.Content = "Button";
btn.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
btn.SetValue(Canvas.LeftProperty, 10.0);
btn.SetValue(Canvas.TopProperty, 10.0);
ctlPOD objPOD = new ctlPOD();
objPOD.AllowDrop = true;
objPOD.Height = 25;
objPOD.Width = 100;
objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
objPOD.SetValue(Canvas.LeftProperty, p.X);
objPOD.SetValue(Canvas.TopProperty, p.Y);
MyPropGrid.ControlToBind = objPOD;
objPOD.cnvPOD.Children.Add(btn);
currentControl = objPOD;
cnvPaint.Children.Add(objPOD);
}
else if ((((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent).GetType() == typeof(ctlPOD))
{
if (currentControl.rect.Visibility == Visibility.Visible)
{
Point p = e.GetPosition((IInputElement)cnvPaint);
((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
}
}
}
else if (e.Data.GetData(typeof(TabControl)) != null)
{
if (((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Name.ToString() == "cnvControls")
{
Point p = e.GetPosition((IInputElement)cnvPaint);
TabControl lbl = new TabControl();
//lbl.Content = "TabControl";
lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
lbl.Height = 25;
lbl.Width = 100;
lbl.PreviewMouseDown += new MouseButtonEventHandler(tabDrag999_PreviewMouseDown);
lbl.SetValue(Canvas.LeftProperty, 10.0);
lbl.SetValue(Canvas.TopProperty, 10.0);
ctlPOD objPOD = new ctlPOD();
objPOD.cnvPOD.Children.Add(lbl);
objPOD.AllowDrop = true;
objPOD.Height = 25;
objPOD.Width = 100;
objPOD.SetValue(Canvas.LeftProperty, p.X);
objPOD.SetValue(Canvas.TopProperty, p.Y);
MyPropGrid.ControlToBind = objPOD;
objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
currentControl = objPOD;
cnvPaint.Children.Add(objPOD);
}
else if ((((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent).GetType() == typeof(ctlPOD))
{
Point p = e.GetPosition((IInputElement)cnvPaint);
((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
}
}
else if (e.Data.GetData(typeof(Label)) != null)
{
if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls")
{
Point p = e.GetPosition((IInputElement)cnvPaint);
Label lbl = new Label();
lbl.Content = "Label";
lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
lbl.Height = 25;
lbl.Width = 100;
lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
lbl.SetValue(Canvas.LeftProperty, 10.0);
lbl.SetValue(Canvas.TopProperty, 10.0);
ctlPOD objPOD = new ctlPOD();
objPOD.cnvPOD.Children.Add(lbl);
objPOD.AllowDrop = true;
objPOD.Height = 25;
objPOD.Width = 100;
objPOD.SetValue(Canvas.LeftProperty, p.X);
objPOD.SetValue(Canvas.TopProperty, p.Y);
MyPropGrid.ControlToBind = objPOD;
objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
//.........这里部分代码省略.........
示例12: UpdateActivatedIndex
private static void UpdateActivatedIndex(ListBox listBox, object value)
{
// find index of activated item
int index;
if (value == null)
{
index = -1;
}
else
{
index = 0;
foreach (var item in listBox.Items)
{
if (item == value)
break;
index++;
}
}
if (index >= listBox.Items.Count)
index = -1;
listBox.SetValue(ActiveIndexPropertyKey, index);
}
示例13: SetIsBroughtIntoViewWhenInserted
public static void SetIsBroughtIntoViewWhenInserted(ListBox listBox, bool value)
{
listBox.SetValue(IsBroughtIntoViewWhenInsertedProperty, value);
}
示例14: createSocket
//Currently creates numeric text boxes
public void createSocket(string type, bool multiple)
{
SocketDragDropTarget target = new SocketDragDropTarget();
target.socketType = type;
Style style = new Style(typeof(ListBoxItem));
style.Setters.Add(new Setter(ListBoxItem.PaddingProperty, new Thickness(-1)));
if (type.Contains("CONDITION"))
target.isCondition = true;
if (type.Contains("CONSTANT"))
target.isConstant = true;
ListBox listBox = new ListBox();
listBox.Height = LayoutRoot.Height - 2;
listBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden);
listBox.ItemContainerStyle = style;
/*if (multiple)
{
listBox.Width = LayoutRoot.Width * .6;
//listBox.MinWidth = LayoutRoot.Width * .75;
//listBox.Width = LayoutRoot.Width * .33;//175;
}
else*/
listBox.Width = LayoutRoot.Width * .75;//350;
listBox.BorderThickness = new Thickness(2);
listBox.Background = new SolidColorBrush(Colors.LightGray);
target.Content = listBox;
innerPane.Children.Add(target);
}
示例15: createParameterList
private void createParameterList()
{
flag_hasSocks = false;
StackPanel webby2 = new StackPanel();
webby2.Orientation = Orientation.Vertical;
innerPane.Children.Add(webby2);
for (int i = 0; i < parameterList.Count; i++)
{
flag_hasSocks = true;
SocketDragDropTarget target = new SocketDragDropTarget();
target.socketType = parameterList[i];
Style style = new Style(typeof(ListBoxItem));
style.Setters.Add(new Setter(ListBoxItem.PaddingProperty, new Thickness(-1)));
if (type.Contains("CONDITION"))
target.isCondition = true;
if (type.Contains("CONSTANT"))
target.isConstant = true;
ListBox listBox = new ListBox();
ObservableCollection<Block> collection = new ObservableCollection<Block>();
listBox.Height = 40;
listBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden);
listBox.ItemContainerStyle = style;
listBox.Width = LayoutRoot.Width * .6;
listBox.BorderThickness = new Thickness(2);
listBox.Background = new SolidColorBrush(Colors.LightGray);
listBox.ItemsSource = collection;
target.Content = listBox;
if(i > 0)
LayoutRoot.Height = LayoutRoot.Height + listBox.Height;
webby2.Children.Add(target);
}
}