日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

listbox wpf 取消边框_停止使用箭头C#WPF导航列表框(Stop listbox from navigating with arrows C# WPF)...

發布時間:2023/12/15 C# 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 listbox wpf 取消边框_停止使用箭头C#WPF导航列表框(Stop listbox from navigating with arrows C# WPF)... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

停止使用箭頭C#WPF導航列表框(Stop listbox from navigating with arrows C# WPF)

我有一個畫布,可以使用箭頭鍵移動元素,但是當我在列表框中選擇當前在畫布上的元素時。 向下箭頭鍵將向下篩選列表,直到它到達底部,然后將在畫布上移動元素。 另一個問題是它會將元素移動到現在選中的列表框的最底部。

I have a canvas which elements can be moved with the arrow keys, however when i select an element in a listbox that is currently on the canvas. The arrow key down will filter down the list until it reaches the bottom then will move the element on the canvas. the other problem is it will then move the element at the very bottom of the listbox that is now selected.

原文:https://stackoverflow.com/questions/42110770

更新時間:2020-10-11 12:10

最滿意答案

您可以處理ListBox的PreviewKeyDown事件:

1

2

3

private void lb_PreviewKeyDown(object sender, KeyEventArgs e)

{

if (e.Key == Key.Down || e.Key == Key.Up)

e.Handled = true;

}

You could handle the PreviewKeyDown event for the ListBox:

1

2

3

private void lb_PreviewKeyDown(object sender, KeyEventArgs e)

{

if (e.Key == Key.Down || e.Key == Key.Up)

e.Handled = true;

}

2017-02-08

相關問答

看看這個問題。 如何使用TwoWay模式將Listview SelectedItem綁定到文本框? 在你的情況下使用

HorizontalAlignment="Left"

Margin="265,148,0,0"

Name="textBox1"

VerticalAlignment="Top" Width="198"

Text="{Binding SelectedItem.Name, ElementName=listBox1}"

...

您可以處理要覆蓋的控件的KeyDown事件。 例如, private void textBox1_KeyDown(object sender, KeyEventArgs e)

{

if (e.KeyCode == Keys.Enter)

{

//execute go button method

GoButtonMethod();

//or if it's an event handler (should be a method)

...

答案是改變更新中的foreach循環 resultsbox.ItemsSource = results;

if (results.Count == 0)

{

foreach (ele item in eles)

{

if (!results.Contains(item.nameElement))

{

results.Add(item.nameElement);

...

有一個如何根據推薦的MVVM設計模式實現這種級聯ComboBox的示例: https : //blog.magnusmontin.net/2013/06/17/cascading-comboboxes-in-wpf-using-mvvm/ 您可以將第一個ListBox的SelectedItem屬性綁定到視圖模型的source屬性。 在這個的setter中,然后設置另一個集合屬性,將第二個ListBox的ItemsSource屬性綁定到,例如:

您添加具有這些屬性的項目,例如匿名對象 : myList.Items.Add(new { Id = "Lorem", ..

...

FoodInformation類不包含屬性: Image和Name (您正嘗試在DataTemplate綁定這些屬性)。 從代碼隱藏中我們可以創建具有屬性Dinner和DinnerImage的FoodInformation類的定義: class FoodInformation

{

public string Dinner { get; set; }

public ImageSource DinnerImage { get; set; }

}

所以你應該綁定屬性Dinner和Din

...

您可以處理ListBox的PreviewKeyDown事件:

1

2

3

private void lb_PreviewKeyDown(object sender, KeyEve

...

GroupModelList/Name在此處不是有效的屬性路徑。 像這樣設置不會使ListBox顯示GroupModelList集合中數據項的Name屬性。 您將不得不設置ListBox的DisplayMemberPath屬性:

DisplayMemberPath="Name"/>

或設置ItemTempl

...

for (int i = 0; i < listBox.Items.Count; i++)

{

var item = listBox.ItemContainerGenerator.ContainerFromItem(listBox.Items[i]) as ListBoxItem;

var template = item.ContentTemplate as DataTemplate;

ContentPres

...

總結

以上是生活随笔為你收集整理的listbox wpf 取消边框_停止使用箭头C#WPF导航列表框(Stop listbox from navigating with arrows C# WPF)...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。