本文整理汇总了C#中System.Windows.Controls.ListBoxItem类的典型用法代码示例。如果您正苦于以下问题:C# ListBoxItem类的具体用法?C# ListBoxItem怎么用?C# ListBoxItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListBoxItem类属于System.Windows.Controls命名空间,在下文中一共展示了ListBoxItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MessageListBox
protected MessageListBox(List<TheoryTypes> items, Mods mod)
{
InitializeComponent();
this.mod = mod;
if (mod == Mods.Edit)
{
throw new NotImplementedException("Так вот.");
}
else if (mod == Mods.Choose)
{
typeOfElement = typeof(TheoryTypes);
ListBox listbox = new ListBox();
ListBoxItem item;
foreach (TheoryTypes type in items)
{
item = new ListBoxItem();
item.Name = type.ToString();
item.Content = type;
listbox.Items.Add(item);
}
listbox.SelectionChanged += new SelectionChangedEventHandler(Listbox_SelectionChanged);
Box.Content = listbox;
}
LanguageResource_Updated(null);
}
示例2: Render
public UIElement Render()
{
var list = new System.Windows.Controls.ListBox();
foreach (var noteItem in this.NoteItems)
{
var renderedNoteItem = noteItem.Render(this.NoteItems.IndexOf(noteItem));
var listNodeItemItem = new ListBoxItem();
listNodeItemItem.Content = renderedNoteItem;
var deleteButtons = (renderedNoteItem as System.Windows.Controls.Panel).Children.OfType<System.Windows.Controls.Button>();
foreach (var delButton in deleteButtons)
{
delButton.PreviewMouseDown += (snd, args) =>
{
//have to find the index of the item, that should be deleted !!!
var toBeDeleted = this.NoteItems[(int)delButton.DataContext];
this.NoteItems.RemoveAt((int)delButton.DataContext); //[index]
list.Items.RemoveAt((int)delButton.DataContext);
RemoveFromFile(toBeDeleted);
CopyData();
};
}
list.Items.Add(listNodeItemItem);
}
return list;
}
示例3: selectFilesButton_Click
private void selectFilesButton_Click(object sender, RoutedEventArgs e)
{
var dlg = new Microsoft.Win32.OpenFileDialog();
dlg.Multiselect = true;
bool? result = dlg.ShowDialog();
if (result == true)
{
dlg.FileNames.ToList().ForEach(filename =>
{
var newItem = new ListBoxItem()
{
Content = System.IO.Path.GetFileName(filename),
Tag = filename
};
ImageFileCollection.Add(newItem);
});
CheckDuplicates();
ValidateInputPage();
}
}
示例4: UserControl_Loaded
private void UserControl_Loaded (object sender, RoutedEventArgs e)
{
listBox1.Items.Clear();
for (int i = 0; i < imageFiles.Count; i++)
{
ListBoxItem lbi = new ListBoxItem();
Image im = new Image();
im.Source = ((ImageInfo)imageFiles[i]).imageSource;
double ratio = im.Source.Height / im.Source.Width;
lbi.Height = ratio * listBox1.Width;
im.Width = 0.9 * listBox1.Width;
im.Height = lbi.Height * 0.9;
lbi.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
im.Stretch = System.Windows.Media.Stretch.Fill;
lbi.Content = im;
listBox1.Items.Add(lbi);
}
if (listBox1.Items.Count > 0)
listBox1.SelectedIndex = 0;
}
示例5: ChangeMCVersion
public ChangeMCVersion()
{
InitializeComponent();
try
{
foreach (TinyMinecraftVersion ver in VersionManager.versions)
{
ListBoxItem item = new ListBoxItem();
item.Content = ver.Key;
item.Tag = ver;
if (ver.Type == ReleaseType.release)
lb_release.Items.Add(item);
else if (ver.Type == ReleaseType.snapshot)
lb_snapshot.Items.Add(item);
else
lb_instance.Items.Add(item);
}
}
catch
{
MessageBox mb = new MessageBox("Warning!","The versions haven't initialized yet");
mb.Show();
this.Close();
}
}
示例6: FillComboBox
public void FillComboBox (ComboBox UsedComboBox, Object Data, String TableName, String ItemName, String ContentToSelect)
{
WCFStandardsNS.TableDescription TableDesc = ClientSchema.TableDictionary [TableName];
WCFStandardsNS.ItemDescription ItemDesc = TableDesc.ItemDictionary [ItemName];
WCFStandardsNS.AssociationDescription Assoc = ItemDesc.GetChildAssociation ();
if (Assoc == null)
return;
DataSet FillDataSet = WCFAccess.GetCommonDataSet (Assoc.ParentTable.SqlFill);
foreach (DataRow FillRow in FillDataSet.Tables [0].Rows)
{
ListBoxItem Item = new ListBoxItem ();
Item.Tag = FillRow;
List<String> DisplayList = new List<string> ();
foreach (String FillItem in Assoc.ParentTable.LinqFillItems)
{
if (FillItem == "ID")
{
if (FillRow [FillItem].ToString () == ContentToSelect)
Item.IsSelected = true;
continue;
}
DisplayList.Add (FillRow [FillItem].ToString ());
}
Item.Content = String.Join (", ", DisplayList.ToArray ());
UsedComboBox.Items.Add (Item);
}
}
示例7: displayMails
internal void displayMails()
{
int id = 0;
LoadingDialog md = new LoadingDialog();
md.Buttons = null;
md.Show();
loadInboxAndSent();
md.Close();
foreach (Mail m in this.mm.Inbox)
{
ListBoxItem newMail = new ListBoxItem();
StackPanel mailContainer = new StackPanel();
Label subject = new Label();
mailContainer.Width = 450;
subject.Tag = id;
subject.Content = m.Title;
mailContainer.Children.Add(subject);
newMail.Content = mailContainer;
this.EmailList.Items.Add(newMail);
id++;
}
}
示例8: MainWindow
public MainWindow()
{
InitializeComponent();
// disable console
tb_console.IsEnabled = false;
for (int i = 0; i < 3; i++) {
ListBoxItem lbi = new ListBoxItem();
lbi.Width = 100;
lbi.Height = 100;
lbi.Content = "test";
lbi.Background = Brushes.Red;
ListBoxProductBacklog.Items.Add(lbi);
}
#region Socket Setup
threadMonitor.ThreadEvent += Thread_MessageReciever;
TcpClient tcpClient = new TcpClient("25.106.204.166", 1234);
//tb_console.Text += "Connected to server.";
sWriter = new StreamWriter(tcpClient.GetStream());
Thread thread = new Thread(Read);
thread.Start(tcpClient);
#endregion
}
示例9: Button_Click
private void Button_Click(object sender, RoutedEventArgs e)
{
if (HasRolled == false)
{
HasRolled = true;
RollButton.Content = "Re-roll Stats";
}
if (Rolls.HasItems == true) Rolls.Items.Clear();
//int[] rolls = new int[4];
//Random r = new Random();
//rolls[0] = r.Next(1, 7);
//rolls[1] = r.Next(1, 7);
//rolls[2] = r.Next(1, 7);
//rolls[3] = r.Next(1, 7);
//int min = rolls.Min();
//int total = rolls.Sum();
//foreach (var roll in rolls)
//{
// Rolls.Items.Add(roll);
//}
//Rolls.Items.Add(min);
//Rolls.Items.Add(total);
Random rr = new Random();
for (int ii = 0; ii < 6; ii++)
{
ListBoxItem lbi = new ListBoxItem();
lbi.Content = RollForIt(rr);
Rolls.Items.Add(lbi);
}
}
示例10: FulcrumWindow
public FulcrumWindow()
{
InitializeComponent();
try
{
//grab the forms associated with the api key and put in the box
fulcrumForms = FulcrumCore.GetForms();
if (fulcrumForms != null)
{
foreach (fulcrumform form in fulcrumForms.forms)
{
ListBoxItem item = new ListBoxItem();
item.Tag = form.id;
item.Content = (form.name);
this.listboxForms.Items.Add(item);
}
}
else
{
MessageBox.Show("Unable to retrieve Fulcrum data at this time.", "Fulcrum Tools", MessageBoxButton.OK, MessageBoxImage.Exclamation);
this.Hide();
}
}
catch (Exception e)
{
string ouch = e.Message;
MessageBox.Show("Unable to retrieve Fulcrum data at this time.", "Fulcrum Tools", MessageBoxButton.OK, MessageBoxImage.Exclamation);
this.Hide();
}
}
示例11: button1_Click
private void button1_Click(object sender, RoutedEventArgs e)
{
var stackPannel = new StackPanel();
var value = new ListBoxItem();
value.Content = "False";
value.Foreground = Brushes.White;
value.Background = Brushes.Red;
value.MouseUp += Value_MouseUp;
var img = new ImgButton()
{
Content = "+",
Width = 30,
Foreground = Brushes.White,
Background = Brushes.YellowGreen
};
img.Click += Img_Click;
stackPannel.Children.Add(new Label() { Content = "Новый элемент" });
stackPannel.Children.Add(value);
stackPannel.Children.Add(img);
stackPannel.Orientation = Orientation.Horizontal;
var item = new ListBoxItem();
item.Content = stackPannel;
item.Selected += Item_Selected;
choices.Items.Add(item);
choices.SelectedItem = item;
}
示例12: IsOnCurrentPage
internal bool IsOnCurrentPage(ListBoxItem item)
{
var itemsHostRect = Rect.Empty;
var listBoxItemRect = Rect.Empty;
if (_visual == null)
{
ItemsControlHelper ich = new ItemsControlHelper(ListBox);
ScrollContentPresenter scp = ich.ScrollHost == null ? null : ich.ScrollHost.GetVisualDescendants().OfType<ScrollContentPresenter>().FirstOrDefault();
_visual = (ich.ScrollHost == null) ? null : ((scp == null) ? ((FrameworkElement)ich.ScrollHost) : ((FrameworkElement)scp));
}
if (_visual == null)
return true;
itemsHostRect = new Rect(0.0, 0.0, _visual.ActualWidth, _visual.ActualHeight);
//ListBoxItem item = ListBox.ItemContainerGenerator.ContainerFromIndex(index) as ListBoxItem;
if (item == null)
{
listBoxItemRect = Rect.Empty;
return false;
}
GeneralTransform transform = item.TransformToVisual(_visual);
listBoxItemRect = new Rect(transform.Transform(new Point()), transform.Transform(new Point(item.ActualWidth, item.ActualHeight)));
if (!this.IsVerticalOrientation())
{
return ((itemsHostRect.Left <= listBoxItemRect.Left) && (listBoxItemRect.Right <= itemsHostRect.Right));
}
return ((listBoxItemRect.Bottom + 100 >= itemsHostRect.Top) && (listBoxItemRect.Top - 100 <= itemsHostRect.Bottom));
//return ((itemsHostRect.Top <= listBoxItemRect.Bottom) && (listBoxItemRect.Top <= itemsHostRect.Bottom));
}
示例13: echo
private void echo(string s, Brush c)
{
ListBoxItem li = new ListBoxItem();
li.Foreground = c;
li.Content = s;
listBox1.Items.Add(li);
}
示例14: newLBitem
private ListBoxItem newLBitem(String name, String tag)
{
ListBoxItem c = new ListBoxItem();
c.Content = name;
c.Tag = tag;
return c;
}
示例15: Load_Networks
private void Load_Networks()
{
string SQL;
string NetID, Netname;
SQL = "select NetworkID, NetName from Networks";
OleDbCommand aCommand = new OleDbCommand(SQL, localengine.RepositoryConnection);
try
{
//create the datareader object to connect to table
OleDbDataReader aReader = aCommand.ExecuteReader();
//Iterate throuth the database
while (aReader.Read())
{
NetID = aReader.GetString(0);
Netname = aReader.GetString(1);
ListBoxItem li = new ListBoxItem();
li.Content = Netname;
li.Tag = NetID;
ContainNetworks.Items.Add(li);
}
aReader.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}