listbox

WPF ListBox Commands within ListBoxItem MVVM Command Binding

橙三吉。 提交于 2019-12-02 10:59:10
I have been trying to find a way to have command buttons within my ListBoxItem's of a ListBox control. I use MVVM and Command Binding to the DataContext via ICommand interface . I am unable to find a way to bind to the Views DataContext from within the ListBox ItemsSource . I continue to get a Command "Not Found" error . Can anyone help me understand how to accomplish this. I believe that it has something to do with the command binding path, but I am unsure. Any help or direction would be great. The DataContext of items in a ListBox will be the item they represent. So if your ItemsSource is

System.MissingMethodException: No parameterless constructor defined for this object

╄→尐↘猪︶ㄣ 提交于 2019-12-02 10:47:25
问题 I'm using MVC 2.0 with a Html.ListBoxFor as below: <% using (Html.BeginForm()) { %> <input type="submit" value=">" /> <%= Html.ListBoxFor(x => x.lstTest, new MultiSelectList(new [] {"someone", "crap", "why"})) %> <% } %> When I click the input submit button below with nothing selected, it posts back fine, when I select one of the 3 items in the listbox it throws this error: System.MissingMethodException: No parameterless constructor defined for this object. Any ideas? here is my controller

File path to file name String converter not working

孤人 提交于 2019-12-02 10:41:43
Using a wpf ListBox I'm trying to display a list of filename without displaying the full path (more convenient for user). Data comes from an ObservableCollection which is filled using Dialog. private ObservableCollection<string> _VidFileDisplay = new ObservableCollection<string>(new[] {""}); public ObservableCollection<string> VidFileDisplay { get { return _VidFileDisplay; } set { _VidFileDisplay = value; } } In the end I want to select some items and get back the full file path. For this I have a converter : public class PathToFilenameConverter : IValueConverter { public object Convert(object

Add students name,surname and age from list to ListBox

允我心安 提交于 2019-12-02 10:35:45
I have 3 textboxes where I can enter Name , Surname and Age . After i press button1, it makes a new student with these attributes. How can I add student with all 3 attributes to ListBox ? Look like this: /#/ -- Name -- Surname -- Age 1 -- John -- Smith -- 21 2 -- Tony -- Hawk -- 22 My code at the moment: public class Students { public string Name; public string Surname; public int Age; } public partial class Form1 : Form { List<Students> group = new List<Students>(); public Form1() { InitializeComponent(); } private void label1_Click(object sender, EventArgs e) { Students student = new

How can I bind against the Index of a ListBoxItem

烂漫一生 提交于 2019-12-02 10:28:38
I'd like to bind the z index of list box items to their index. Ideally, we would have <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Panel.ZIndex" Value="{Binding RelativeSource={RelativeSource Self}, Path=-Index}" /> <!-- ... --> However, the list box item does not have an index property. I can think of a number of crazy solutions but nothing simple and elegant. Any taker? There is no Index property, but anyway "-Index" wouldn't be a valid path... you would still need a converter to negate the value. So what you can do is create a converter that retrieves the index from the

Direct Uploading New Ftp listbox Lines

▼魔方 西西 提交于 2019-12-02 10:15:30
Can i (Upload / Adding) Listbox Lines To Current Ftp listbox Lines Server Without download Previous ftp server Listbox value. Instead of Uploading addition listbox lines To Ftp Listbox Lines Server ! Can I simply send listbox new lines and then it Added to currently listbox ftp server lines (without remove old lines, it only add new lines) With currently Ftp listbox Lines without me having to download and upload the whole ftp listbox? Example : That's My Code Download Code (Button 1) [not important] Dim request As FtpWebRequest = WebRequest.Create("ftp://test.com/test.txt") request.Method =

Populate WPF listbox based on selection of another listbox

淺唱寂寞╮ 提交于 2019-12-02 10:08:05
I have a listbox that is bound to an observablecollection. The observable collection contains a list of objects, each with it's own observablecollection. What i want is to click an item in the first listbox and have it's list of things displayed in the second listbox. Can I do this in pure WPF? Just bind the ItemsSource of the second listbox to the SelectedItem of the first list box. Edit: here is some code. public partial class MainWindow : Window { public MainWindow() { TestItems = new ObservableCollection<Test>(); InitializeComponent(); for (int i = 0; i < 5; i++) TestItems.Add(InitTest(i))

How can i call the below function to populate my access form list control

主宰稳场 提交于 2019-12-02 10:06:06
I need to populate the access form list box from a access table. Below is the code which I copy-pasted on button click event: Public Sub PopulateLBWithData(DBPath As String, _ TableName As String, FieldName As String, _ oListControl As Object,Optional Distinct As Boolean = False, _ Optional OrderBy As String) ''#PURPOSE: Populate a list box, combo box ''#or control with similar interface with data ''#from one field in a Access Database table ''#Parameters: DBPath: FullPath to Database ''#TableName: The Name of the Table ''#FieldName: Name of the Field ''#Distinct: Optional -- True if you want

Wpf ListBox – change default selected-item style *inside* the ContentPresenter

喜你入骨 提交于 2019-12-02 09:57:48
I have a ListBox in which each item is a StackPanel. The StackPanel consist of an Image and a TextBlock below it: <ListBox.ItemTemplate> <DataTemplate> <StackPanel Margin="10"> <Image> <Image.Source> <BitmapImage UriSource="{Binding Path=ImageFilePath}"/> </Image.Source> </Image> <TextBlock Text="Title" TextAlignment="Center"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> It looks like this: When the user select an item, I get the default blue rectangle that surround the StackPanel: Now, I want to make a different border for the selected-item, but I want it to surround only the image

Automatically filter/order ListBox items (Windows Phone)

北城以北 提交于 2019-12-02 09:32:15
I want to ensure, that the items added in my list box are ordered in ascending order according to the serial number of each item (e.g 1 item, 2 item, 4 item, 3 item should be automatically order according to its number 1.2.3.......10). Here is the C# source: namespace XeroQuiz { public partial class MainPage : PhoneApplicationPage { IsolatedStorageFile Settings1 = IsolatedStorageFile.GetUserStoreForApplication(); MyDataList listobj = new MyDataList(); public MainPage() { InitializeComponent(); this.Loaded += MainPage_Loaded; this.FavoriteListBox.Visibility = Visibility.Collapsed; if (Settings1