[英]combobox items appear outside combobox
我認為以下圖片足以說明問題。
在我的Windows Phone 7應用程序(C#)中,我有一個綁定框,它綁定了一些數據(StatusNameAsceding,StatusNameDesceding等)
如您所見,下拉菜單似乎完全空白,並且其項目顯示在下拉菜單中,但所選項目除外。 任何想法。
更新...我使用的代碼
用於組合框...(xaml頁)
<ComboBox SelectionChanged="OnSortingColumnChanged"
x:Name="SortingColumn" Margin="2,0,0,0" Foreground="Black"
VerticalContentAlignment="Center" Padding="0">
在App.xaml.cs中
public enum SortingColumns
{
StatusNameAscending = 0,
StatusNameDescending,
EXAMINOAscending,
EXAMINODescending,
}
public SortingColumns SortingColumn { get; set; }
在后面的代碼中(page.xaml.cs)
this.DataContext = CreateSampleData();
App.Current.SortingColumn = App.SortingColumns.StatusNameAscending;
SortingColumn.Items.Add(App.SortingColumns.StatusNameAscending.ToString());
SortingColumn.Items.Add(App.SortingColumns.StatusNameDescending.ToString());
SortingColumn.Items.Add(App.SortingColumns.EXAMINOAscending.ToString());
SortingColumn.Items.Add(App.SortingColumns.EXAMINODescending.ToString());
SortingColumn.SelectedIndex = (int)App.Current.SortingColumn;
和...
private void OnSortingColumnChanged(object sender, SelectionChangedEventArgs e)
{
App.Current.SortingColumn = (App.SortingColumns)SortingColumn.SelectedIndex;
// Rebind
// The List control binds the data again when a different datacontext is set.
var datacontext = DataContext;
DataContext = null;
DataContext = datacontext;
}
UPDATE2 ...當我在空白列表中單擊時,發生選擇更改並應用了排序,我認為組合框模板中發生了某些錯誤,但是我不知道該怎么辦! 任何想法? 提前致謝!
最后,我使用列表選擇器而不是組合框
<toolkit:ListPicker SelectionChanged="OnSortingColumnChanged" x:Name="SortingColumn" Margin="2,0,0,0" Foreground="Black" Width="300" Height="180" FontSize="18"></toolkit:ListPicker>
一些細節...
首先,您必須為Windows Phone安裝Silverlight工具。 您可以在這里下載: http : //silverlight.codeplex.com/releases/view/71550
然后,我們轉到AnyPage.xaml並構建了一個示例用戶界面,但在此之后,我們聲明如下:
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
其余代碼保持不變。 有關列表選擇器的更多信息,請在這里查看
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.