Forums - C# Corner

Forum guidelines
Sebastian

Sebastian

  • 1.3k
  • 1
  • 1.2k

Listbox, DepedencyProperty, primary questions

Dec 13 2012 3:05 PM
Hello, I've started to programming Aplplications in WPF and I have very simple questions, because I don't understand most of courses in the Internet.


1. What is DependencyProperty and how can I use it for example - it is to change parameters in XAML code ?


2. I have some Listboxes and I'd like to add some entires to list by this application - how can I do it ?


XAML:


xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">

















Background="Beige">

























C# code:




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
///
/// Interaction logic for MainWindow.xaml
///

public partial class MainWindow : Window
{
CompositeCollection[] lista = new CompositeCollection[]
{
new CompositeCollection{imie = "Janusz", nazwisko = "Nowak"},
new CompositeCollection{imie = "Jan", nazwisko = "Kowalski"}
};
public MainWindow()
{
InitializeComponent();
listboks.ItemsSource = lista;
}
private void dodaj(object sender, RoutedEventArgs e)
{
if ((imiee.Text != "") && (nazwiskoo.Text != ""))
{
listboks.Items.Add(imiee.Text);
listboks.Items.Add(nazwiskoo.Text);
}
else MessageBox.Show("Podaj imie oraz nazwisko!");
}
 private void clear(object sender, RoutedEventArgs e) 
{
listboks.ItemsSource.GetHashCode();
}
 private void exit(object sender, RoutedEventArgs e) 
{
this.Close();
}
 private void remove(object sender, RoutedEventArgs e) 
{
}
}
class CompositeCollection
{
public string imie
{
get;
set;
}
public string nazwisko
{
get;
set;
}
}
}






Please, give me only simple examples


Thanks. 

Unlimited Flat-Free License

SPONSORED BY

File APIs for .NET
Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!