本文整理汇总了C#中System.Windows.Controls.ListBox类的典型用法代码示例。如果您正苦于以下问题:C# ListBox类的具体用法?C# ListBox怎么用?C# ListBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListBox类属于System.Windows.Controls命名空间,在下文中一共展示了ListBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AutoScrollHandler
public AutoScrollHandler(System.Windows.Controls.ListBox target)
{
Target = target;
Binding B = new Binding("ItemsSource");
B.Source = Target;
BindingOperations.SetBinding(this, ItemsSourceProperty, B);
}
开发者ID:Kayomani,项目名称:FAP,代码行数:7,代码来源:ListBoxAutoScroll.cs
示例2: GetContent
protected override FrameworkElement GetContent()
{
int totalHeight = 0;
ListBox removeOptions = new ListBox();
for(int i = 0 ; i < _tree.Items.Count; i ++)
if (_tree.Items[i] is PatternBase)
{
totalHeight += 25; //default height of an item
TextBlock pattern = new TextBlock()
{
Text = (_tree.Items[i] as PatternBase).BioPatternName,
Name = i.ToString(), //store the id as name so we can remove it later...
Width = 150
};
pattern.MouseLeftButtonUp += new MouseButtonEventHandler(RemoveSelectedPattern);
removeOptions.Items.Add(pattern);
}
Grid grid = new Grid()
{
Height = totalHeight,
Width = 170
};
grid.Children.Add(removeOptions);
return grid;
}
开发者ID:SamuelToh,项目名称:Masters_Degree_Major_Project,代码行数:29,代码来源:PatternRemoveMenu.cs
示例3: fillList
private void fillList(ListBox listPlaylist)
{
if (!Directory.Exists(PathPlaylist))
Directory.CreateDirectory(PathPlaylist);
try
{
string[] listFiles = Directory.GetFiles(PathPlaylist, "*.pls");
foreach (string fileName in listFiles)
{
try
{
Playlist onePlaylist = new Playlist(fileName);
onePlaylist.ParsePlaylist();
listPlaylist.Items.Add(onePlaylist);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
开发者ID:Cathret,项目名称:MyWindowsMediaPlayer,代码行数:26,代码来源:ViewModelPlaylist.cs
示例4: AddSelectionEvent
static void AddSelectionEvent(ListBox list)
{
list.SelectionChanged += delegate
{
MessageBox.Show("");
};
}
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:7,代码来源:WPFListBoxTest.cs
示例5: GetInformationToSave
private static string GetInformationToSave(int cas, MainWindow mw)
{
ListBox listBox = new ListBox();
switch (cas)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
listBox = mw.listBoxError_Test;
break;
}
string contents = "";
foreach (string ligne in listBox.Items)
{
contents += ligne + "\r\n";
}
return contents;
}
开发者ID:unil,项目名称:fbm-tools,代码行数:27,代码来源:Save.cs
示例6: switch
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.remoteClientList = ((System.Windows.Controls.ListBox)(target));
return;
case 2:
#line 18 "..\..\AddAppDialog.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OKButton_Clicked);
#line default
#line hidden
return;
case 3:
#line 20 "..\..\AddAppDialog.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.CancelButton_Clicked);
#line default
#line hidden
return;
}
this._contentLoaded = true;
}
开发者ID:Microsoft,项目名称:HoloToolkit,代码行数:25,代码来源:AddAppDialog.g.i.cs
示例7: OnApplyTemplate
public override void OnApplyTemplate()
{
if (ResultsListBox != null)
ResultsListBox.SelectionChanged -= ResultListBox_SelectionChanged;
if (MapDetailsControl != null)
{
MapDetailsControl.MapDetailsChanged -= RaiseMapDetailsChanged;
MapDetailsControl.MapSelectedForOpening -= RaiseMapSelectedForOpening;
}
base.OnApplyTemplate();
MapDetailsControl = GetTemplateChild("MapDetailsControl") as MapDetailsControl;
ResultsListBox = GetTemplateChild("ResultsListBox") as ListBox;
if (ResultsListBox != null)
{
ResultsListBox.SelectionChanged += ResultListBox_SelectionChanged;
ResultsListBox.Tag = this;
}
if (MapDetailsControl != null)
{
MapDetailsControl.MapDetailsChanged += RaiseMapDetailsChanged;
MapDetailsControl.MapSelectedForOpening += RaiseMapSelectedForOpening;
}
}
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:25,代码来源:FeaturedMapsControl.xaml.cs
示例8: ListColorNames
public ListColorNames()
{
Title = "List Color Names";
ListBox lstbox = new ListBox();
lstbox.Width = 150; // ��
lstbox.Height = 150; //����
lstbox.SelectionChanged += ListBoxOnSelectionChanged; // �̺�Ʈ ���
Content = lstbox; //win�� ���(ȭ�鿡 ���)
//1��
/*
//��������� ListBox�� ü���
PropertyInfo[] props = typeof(Colors).GetProperties();
//GetProperties �� Colors�� �ִ� ������Ƽ 141���� �迭�� �����´�.
//������ PropertyInfo Ÿ���� �迭�� �ϳ��� ������ Name���� �̸��� ����Ʈ �ڽ��� �߰��Ѵ�.
foreach (PropertyInfo prop in props)
lstbox.Items.Add(prop.Name);
*/
//2��
PropertyInfo[] props = typeof(Colors).GetProperties();
//����Ʈ �ڽ��� Color ������ ü���...
foreach (PropertyInfo prop in props)
lstbox.Items.Add(prop.GetValue(null, null));
}
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:27,代码来源:ListColorNames.cs
示例9: CreateAndInitListBox
private ListBox CreateAndInitListBox()
{
ListBox lst = new ListBox();
lst.Margin = new Thickness(10, 10, 10, 10);
return lst;
}
开发者ID:expanz,项目名称:expanz-Microsoft-XAML-SDKs,代码行数:7,代码来源:ClientMessageControl.xaml.cs
示例10: worker_RunWorkerCompleted
void worker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{
var winFabSortedList = winFabInterest;
ListBox lstBx = new ListBox();
lstBx.Height = this.MainPanel.Height;
lstBx.Width = this.MainPanel.Width;
this.MainPanel.Children.Add(lstBx);
if (winFabSortedList.Count == 0)
{
MessageBox.Show("No Records Found.Try changing the folder option.");
}
else
{
foreach (var itm in winFabSortedList)
{
EmailDataModel emailObj = new EmailDataModel();
emailObj.SenderName = itm.SenderName;
emailObj.SenderGroup = itm.SenderGroup;
emailObj.SenderParticipation = itm.SenderParticipation;
emailObj.SenderContact = itm.SenderContact;
InterestControl intControl = new InterestControl();
intControl.SetUI(emailObj);
lstBx.Items.Add(intControl);
}
}
this.EllipseAnimate.Visibility = Visibility.Collapsed;
this.EllipseAnimate.Visibility = Visibility.Collapsed;
this.UpdateLayout();
}
开发者ID:Nabarun,项目名称:OutlookAnalyzer,代码行数:29,代码来源:MainWindow.xaml.cs
示例11: IsFirstItemVisible
public static bool IsFirstItemVisible(ListBox listbox)
{
if (listbox.Items.Count == 0)
return false;
var listboxRectangle = new Rect(new Point(0, 0), listbox.RenderSize);
double visiblePercent = 0;
ListBoxItem item = listbox.ItemContainerGenerator.ContainerFromIndex(0) as ListBoxItem;
if (item != null)
{
var itemTransform = item.TransformToVisual(listbox);
var itemRectangle = itemTransform.TransformBounds(new Rect(new Point(0, 0), item.RenderSize));
itemRectangle.Intersect(listboxRectangle);
if (!itemRectangle.IsEmpty)
{
visiblePercent = itemRectangle.Height / item.RenderSize.Height * 100;
}
}
if (visiblePercent > 0)
return true;
else
return false;
}
开发者ID:optiklab,项目名称:VKMessanger,代码行数:27,代码来源:WindowsPhoneHelpers.cs
示例12: AddItemToList
public void AddItemToList(RecognitionResult speech, ListBox list, Color color)
{
ListBoxItem item = CreateDefaultListBoxItem();
item.Content = "S:" + speech.Text + " C:" + speech.Confidence;
item.Foreground = new SolidColorBrush(color);
AddToList(list, item);
}
开发者ID:LucioC,项目名称:class_share,代码行数:7,代码来源:ListBoxHelper.cs
示例13: ListColorsEvenElegantlier
public ListColorsEvenElegantlier()
{
Title = "List Colors Even Elegantlier";
DataTemplate template = new DataTemplate(typeof(NamedBrush));
FrameworkElementFactory factoryStack = new FrameworkElementFactory(typeof(StackPanel));
factoryStack.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
template.VisualTree = factoryStack;
FrameworkElementFactory factoryRectangle = new FrameworkElementFactory(typeof(Rectangle));
factoryRectangle.SetValue(Rectangle.WidthProperty, 16.0);
factoryRectangle.SetValue(Rectangle.HeightProperty, 16.0);
factoryRectangle.SetValue(Rectangle.MarginProperty, new Thickness(2));
factoryRectangle.SetValue(Rectangle.StrokeProperty, SystemColors.WindowTextBrush);
factoryRectangle.SetBinding(Rectangle.FillProperty, new Binding("Brush"));
factoryStack.AppendChild(factoryRectangle);
FrameworkElementFactory factoryTextBlock = new FrameworkElementFactory(typeof(TextBlock));
factoryTextBlock.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
factoryTextBlock.SetValue(TextBlock.TextProperty, new Binding("Name"));
factoryStack.AppendChild(factoryTextBlock);
ListBox lstbox = new ListBox();
lstbox.Width = 150;
lstbox.Height = 150;
Content = lstbox;
lstbox.ItemTemplate = template;
lstbox.ItemsSource = NamedBrush.All;
lstbox.SelectedValuePath = "Brush";
lstbox.SetBinding(ListBox.SelectedValueProperty, "Background");
lstbox.DataContext = this;
}
开发者ID:JianchengZh,项目名称:kasicass,代码行数:34,代码来源:ListColorsEvenElegantlier.cs
示例14: switch
void IComponentConnector.Connect(int connectionId, object target)
{
switch (connectionId)
{
case 1:
this.syncMovies = (CheckBox) target;
return;
case 2:
this.syncMoviesAll = (CheckBox) target;
return;
case 3:
this.moviesListBox = (ListBox) target;
this.moviesListBox.PreviewKeyDown += new KeyEventHandler(this.listBox_PreviewKeyDown);
return;
case 4:
this.drmMessage = (TextBlock) target;
return;
case 5:
this.cancelButton = (Button) target;
return;
case 6:
this.syncButton = (Button) target;
return;
}
this._contentLoaded = true;
}
开发者ID:netonjm,项目名称:WindowsPhone,代码行数:31,代码来源:PCMoviesPanel.cs
示例15: show
public void show(MainWindow con, ListBox lb, string kto, string text, int tem)
{
if (!lb.CheckAccess())
{
con.Dispatcher.Invoke(DispatcherPriority.Send,
(Action)delegate
{
UserWiad itm = new UserWiad();
itm.Nick = kto;
itm.Wiad = text;
itm.Typ = tem;
lb.Items.Add(itm);
lb.ScrollIntoView(itm);
});
}
else
{
UserWiad itm = new UserWiad();
itm.Nick = kto;
itm.Wiad = text;
itm.Typ = tem;
lb.Items.Add(itm);
lb.ScrollIntoView(itm);
}
}
开发者ID:MichalPL,项目名称:C-Sharp-Moje-Projekty,代码行数:26,代码来源:NewMessage.cs
示例16: WhenDataContextChanges_ThenItupdatesSelectedItems
public void WhenDataContextChanges_ThenItupdatesSelectedItems()
{
var behavior = new SynchronizeSelectedItems();
BindingOperations.SetBinding(
behavior,
SynchronizeSelectedItems.SelectionsProperty,
new Binding("ObservableSelections"));
var listBox = new ListBox() { SelectionMode = SelectionMode.Multiple };
BindingOperations.SetBinding(
listBox, ListBox.ItemsSourceProperty,
new Binding("Items"));
listBox.DataContext =
new ItemsHolder
{
Items = { "a", "b", "c", "d" },
ObservableSelections = { "a", "c" }
};
var behaviors = Interaction.GetBehaviors(listBox);
behaviors.Add(behavior);
listBox.DataContext =
new ItemsHolder
{
Items = { "a", "b", "c", "d" },
ObservableSelections = { "b", "d" }
};
CollectionAssert.AreEquivalent(new[] { "b", "d" }, listBox.SelectedItems);
}
开发者ID:CarlosVV,项目名称:mediavf,代码行数:32,代码来源:SynchronizeSelectedItemsFixture.cs
示例17: Test
public void Test(int processId)
{
IEnumerable<string> fontFamilies = System.Drawing.FontFamily.Families.Select(f=>f.Name);
ListBox listBox = new ListBox();
ResourceDictionary dictionary = new ResourceDictionary();
dictionary.Source = new Uri("/KSPE3Lib;component/Resources.xaml", UriKind.Relative);
listBox.ItemTemplate = dictionary["FontItemTemplate"] as DataTemplate;
listBox.ItemsSource = fontFamilies;
listBox.Width = 250;
listBox.Height = 300;
listBox.SelectionChanged += listBox_SelectionChanged;
Dictionary<int, Color> colorByCode = E3ColorTable.GetColorByCode(processId);
ColorPicker colorPicker = new ColorPicker(colorByCode);
colorPicker.VerticalAlignment = VerticalAlignment.Center;
colorPicker.SelectedColorChanged += colorPicker_SelectedColorChanged;
textBlockForeGroundBrush = new SolidColorBrush();
textBlockForeGroundBrush.Color = colorPicker.SelectedColor;
textBlock = new TextBlock();
textBlock.Text = "Example";
textBlock.Foreground = textBlockForeGroundBrush;
StackPanel panel = new StackPanel();
panel.Background = new SolidColorBrush(Colors.LightGray);
panel.Children.Add(textBlock);
panel.Children.Add(colorPicker.UIElement);
panel.Children.Add(listBox);
panel.Orientation = Orientation.Horizontal;
Content = panel;
}
开发者ID:Genotoxicity,项目名称:KSPE3Lib,代码行数:28,代码来源:FontSettingsWindow.cs
示例18: GetDataFromListBox
private static object GetDataFromListBox(ListBox source, Point point)
{
UIElement element = source.InputHitTest(point) as UIElement;
if (element != null)
{
object data = DependencyProperty.UnsetValue;
while (data == DependencyProperty.UnsetValue)
{
data = source.ItemContainerGenerator.ItemFromContainer(element);
if (data == DependencyProperty.UnsetValue)
{
element = VisualTreeHelper.GetParent(element) as UIElement;
}
if (element == source)
{
return null;
}
}
if (data != DependencyProperty.UnsetValue)
{
return data;
}
}
return null;
}
开发者ID:gxconsultancyltd,项目名称:GX-Work-Assistant,代码行数:25,代码来源:MainWindow.xaml.cs
示例19: Setup_Board
public void Setup_Board(Tuple<IEnumerable<Column>, IEnumerable<Task>> columns_and_tasks) {
listboxes = new List<ListBox>();
var columnIndex = 0;
foreach (var column in columns_and_tasks.Item1) {
var listbox = new ListBox();
listbox.MinWidth = 64;
panel.Children.Add(listbox);
var col = columnIndex++;
listbox.SelectionChanged += (o, e) => {
if (listbox.SelectedIndex == -1) {
return;
}
for (var i = 0; i < listboxes.Count; i++) {
if (i == col) {
continue;
}
listboxes[i].SelectedIndex = -1;
}
Show_Task(col, listbox.SelectedIndex);
};
listboxes.Add(listbox);
}
foreach (var task in columns_and_tasks.Item2) {
Add_Task(task);
}
}
开发者ID:slieser,项目名称:sandbox,代码行数:27,代码来源:BoardUI.xaml.cs
示例20: Discard
private void Discard(ListBox menu)
{
menu.IsEnabled = false;
var duration = new Duration(TimeSpan.FromMilliseconds(400));
DoubleAnimation
posXAnimation = new DoubleAnimation { Duration = duration, To = -80 },
posYAnimation = new DoubleAnimation { Duration = duration, To = -80 },
scaleXAnimation = new DoubleAnimation { Duration = duration, To = 1.5 },
scaleYAnimation = new DoubleAnimation { Duration = duration, To = 1.5 },
opacityAnimation = new DoubleAnimation { Duration = duration, To = 0 }
;
var translateTransform = ((TransformGroup)menu.RenderTransform).Children[0];
var scaleTransform = ((TransformGroup)menu.RenderTransform).Children[1];
translateTransform.BeginAnimation(TranslateTransform.XProperty, posXAnimation);
translateTransform.BeginAnimation(TranslateTransform.YProperty, posYAnimation);
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleXAnimation);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleYAnimation);
opacityAnimation.Completed += (object sender, EventArgs e) =>
{
menu.Visibility = Visibility.Collapsed;
menu.IsEnabled = true;
translateTransform.BeginAnimation(TranslateTransform.XProperty, null);
translateTransform.BeginAnimation(TranslateTransform.YProperty, null);
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, null);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, null);
menu.BeginAnimation(OpacityProperty, null);
};
menu.BeginAnimation(OpacityProperty, opacityAnimation);
}
开发者ID:kpozin,项目名称:kinect_menu,代码行数:29,代码来源:MainWindow.xaml.cs
注:本文中的System.Windows.Controls.ListBox类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论