Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ComboBox ItemsSource="{Binding AllCustomers}" IsEditable="True"/>
- <ComboBox ItemsSource="{Binding AllCustomers}" DisplayMemberPath="CustomerName" IsEditable="True"/>
- <ComboBox ItemsSource="{Binding AllCustomers}" SelectedValue="CustomerName" IsEditable="True">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding CustomerName}"/>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ComboBox>
- public class AllCustomersViewModel
- {
- public ObservableCollection<CustomerViewModel> AllCustomers {get; set;}
- }
- public class CustomerViewModel
- {
- public string CustomerName;
- public short CustomerID;
- }
- public class AccountTransactionsViewModel
- {
- DataRepository _repository;
- public AccountTransactionsViewModel()
- {
- _repository = new DataRepository();
- CreateAccountsViewModel();
- }
- public ObservableCollection<AccountViewModel> AllAccounts { get; set; }
- void CreateAccountsViewModel()
- {
- List<AccountViewModel> allAccounts = _repository.GetAccounts()
- .Select(a => new AccountViewModel(a, _repository))
- .ToList();
- AllAccounts = new ObservableCollection<AccountViewModel>(allAccounts);
- }
- }
- public class AccountViewModel
- {
- Account _account;
- DataRepository _repository;
- public AccountViewModel(Account account, DataRepository repository)
- {
- _account = account;
- _repository = repository;
- }
- public short AccountID { get { return _account.AccountID; } set { } }
- public string AccountName { get { return _account.AccountName; } set { } }
- }
- <ComboBox Name="customerCombobox" ItemsSource="{Binding AllAccounts}" IsEditable="True">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding AccountName}"/>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ComboBox>
- <ComboBox ItemsSource="{Binding AllCustomers}" SelectedValue="CustomerName">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding Item.CustomerName}"/>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ComboBox>
- <ComboBox Name="customerCombobox" ItemsSource="{Binding AllAccounts}" SelectedValuePath="AccountName">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding AccountName}"/>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ComboBox>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement