我在Silverlight组合框中遇到了一些奇怪的行为。我从一些简单的代码开始:
XAML:
<ComboBox Name="drpInstallation" SelectionChanged="drpInstallation_SelectionChanged" />
反恐精英:
List<string> installations = new List<string>();
installations.Add("Testing 123");
installations.Add("Antoher test");
installations.Add("Yeah");
drpInstallation.ItemsSource = installations;
单击某个项目时,一切都正常。但是,如果我使用如下组合框中的项模板:
XAML:
<ComboBox Name="drpInstallation" SelectionChanged="drpInstallation_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<ComboBoxItem Content="{Binding Installation}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
反恐精英:
ICollection<InstallationClass> installations = a list of the installation class;
drpInstallation.ItemsSource = installations;
安装类.cs:
public class InstallationClass
{
public int PK;
public string Installation;
}
现在,组合框正确显示,但是当我单击
文本
如果没有发生任何事情。如果我只单击文本本身的右侧,则该项将像正常一样被选中。重点是;自然的做法是单击文本本身,而不是单击文本的左侧或右侧。知道为什么会发生这种情况,知道如何纠正吗?这是Silverlight错误吗?