First, thank you arussel for your helpful comments. I have found and am now able to recreate the bazaar behavior I experienced with the WPF comboboxes. It all boils down to sloppy use of cut and paste operations in creating a new UI. Essentially, in creating cboCatagory I copied and pasted the XAML code for cboSubCatagory and then changed SubCategory to Category in the appropriate places. This action also apparently created a “DropDownClosed” event and corresponding “DropDownClosed” event handler for cboCatagory. In creating the code behind, again I must have copied and pasted a second copy of the “DropDownClosed” event handler, i.e. cboCatagory_DropDownClosed_1. Somehow this 2nd copy contained the objectionable statement:
Category = cboSubCategory.Text;
The attached code (XAML and C# code behind) recreates the bazaar behavior I was observing. Again, thank you for your input it lead ne in the right direction and encouraged me to follow through to find what was going on.
I actually developed this “on the side” application to investigate another problem; the scrolling behavior of the WPF listbox (in so doing I spent the last 10 days trying to get it to work). I will pose my scrolling problem in another question.
ttyler
XAML:
<window x:class="ComboBoxTester.MainWindow" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Reconstruct" Height="450" Width="800">
<grid x:name="grdContent" horizontalalignment="Left" background="AliceBlue" margin="10">
<grid.rowdefinitions>
<rowdefinition height="Auto" minheight="150" />
<rowdefinition height="*" />
</grid.rowdefinitions>
<grid.columndefinitions>
<columndefinition width="150" />
<columndefinition width="640" />
</grid.columndefinitions>
<stackpanel x:name="stkButtons" width="Auto" height="Auto" margin="5,5,5,5">
<button x:name="btnReturn" content="Return" horizontalalignment="Left" verticalalignment="Top">
MinWidth="75" Height="35" Margin="5,10,0,5" Click="btnReturn_Click"/>
</button></stackpanel>
<wrappanel x:name="wrpListBoxes" width="Auto" maxheight="120" grid.row="0" grid.column="1">
Margin="30,10,30,10" Orientation="Horizontal" Background="AliceBlue">
<listbox x:name="lstBroker" width="125" height="Auto" minheight="50">
Margin="100,10,0,5" HorizontalAlignment="Center" VerticalAlignment="Center"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" Background="LightYellow"/>
<listbox x:name="lstCatagory" width="125" height="Auto" minheight="50">
Margin="5,10,0,5" HorizontalAlignment="Center" VerticalAlignment="Center"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" Background="LightYellow"/>
<listbox x:name="lstSubCatagory" width="125" height="Auto" minheight="50">
Margin="5,10,0,5" HorizontalAlignment="Center" VerticalAlignment="Center"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" Background="LightYellow"/>
</listbox></listbox></listbox></wrappanel>
<wrappanel x:name="wrpComboBoxes" width="Auto" height="Auto" grid.row="1" grid.column="1">
Margin="30,5,30,10" Orientation="Horizontal" Background="AliceBlue" >
<combobox x:name="cboBroker" width="125" height="20" margin="100,10,0,0">
HorizontalAlignment="center" VerticalAlignment="Center" Background="PaleGreen"
ItemsSource="{Binding Path=EntryList}" DisplayMemberPath="Broker"
DropDownClosed="cboBroker_DropDownClosed" />
<combobox x:name="cboCatagory" width="125" height="20" margin="5,10,0,0">
HorizontalAlignment="Left" VerticalAlignment="Top" Background="PaleGreen"
ItemsSource="{Binding Path=EntryList}" DisplayMemberPath="Catagory"
DropDownClosed="cboCatagory_DropDownClosed_1" />
<combobox x:name="cboSubCatagory" width="125" height="20" margin="5,10,0,0">
HorizontalAlignment="Left" VerticalAlignment="Top" Background="PaleGreen"
ItemsSource="{Binding Path=EntryList}" DisplayMemberPath="SubCatagory"
DropDownClosed="cboSubCatagory_DropDownClosed" />
</combobox></combobox></combobox></wrappanel>
</grid>
</window>
Code behind:
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
namespace ComboBoxTester
{
public partial class MainWindow : Window
{
string Broker;
string Catagory;
string SubCatagory;
int i = 0;
string Num;
Transactions transaction = new Transactions();
List<transactions> EntryList = new List<transactions>();
public MainWindow()
{
InitializeComponent();
for(i= 1; i<=10; i++)
{
Num = i.ToString();
Broker = "Broker" + Num;
Catagory = "Catagory" + Num;
SubCatagory = "SubCatagory" + Num;
EntryList.Add(new Transactions() { Broker = Broker, Catagory = Catagory, SubCatagory = SubCatagory });
}
cboBroker.ItemsSource = EntryList;
cboCatagory.ItemsSource = EntryList;
cboSubCatagory.ItemsSource = EntryList;
}
private void btnReturn_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
private void cboBroker_DropDownClosed(object sender, EventArgs e)
{
Broker = cboBroker.Text;
lstBroker.Items.Add(Broker);
}
private void cboCatagory_DropDownClosed(object sender, EventArgs e)
{
Catagory = cboCatagory.Text;
lstCatagory.Items.Add(Catagory);
}
private void cboSubCatagory_DropDownClosed(object sender, EventArgs e)
{
SubCatagory = cboSubCatagory.Text;
lstSubCatagory.Items.Add(SubCatagory);
}
private void cboCatagory_DropDownClosed_1(object sender, EventArgs e)
{
Catagory = cboSubCatagory.Text;
lstCatagory.Items.Add(Catagory);
}
public class Transactions
{
public string Broker { get; set; }
public string Catagory { get; set; }
public string SubCatagory { get; set; }
}
}
}
</transaction></transactions></transactions>