我的組合框項目未顯示。它在Visual Studio 2015上運行良好。但是,當我在Visual Studio 2013中嘗試這個功能時,它什麼也沒有顯示。我在ComboBox_Loaded函數中設置了調試點,從中我看到最後3行被編譯器忽略。我如何解決它的Visual Studio 2013.在此先感謝。ComboBox項目未加載WPF
<Window x:Class="GraphicalUserInterface.ShowDataByObjectsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ShowDataByObjectsWindow" Height="300" Width="300">
<Grid Background="#FFE5E5E5">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="10">
<TextBlock FontWeight="Bold" Text="Object Options"/>
<ComboBox x:Name="dbObjects" Loaded="ComboBox_Loaded" SelectionChanged="ComboBox_SelectionChanged"/>
</StackPanel>
</Grid>
public partial class ShowDataByObjectsWindow : Window
{
public List<string> dataTableName = new List<string>();
public static string comboItem;
public ShowDataByObjectsWindow()
{
InitializeComponent();
}
private void ComboBox_Loaded(object sender, RoutedEventArgs e)
{
dataTableName.Add("adasd");
dataTableName.Add("adaasdsd");
var comboBox = sender as ComboBox;
comboBox.ItemsSource = dataTableName;
comboBox.SelectedIndex = 0;
}
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var comboBox = sender as ComboBox;
string value = comboBox.SelectedItem as string;
this.Title = "Selected: " + value;
}
}
「我已經看到最後3行被編譯器跳過了」:嘗試清理並強制重建項目。看起來你運行的是WPF應用程序的老式版本。 –
我已經清理並再次重建。它仍然是一樣的。沒有更新 – Aarav