selectionchanged

How listview selection changed event work. It called twise

≡放荡痞女 提交于 2020-01-21 19:53:52
问题 I have list view control where on change of selection, I do check - if selected record count is greater then zero then only enable group box controls else keep it disable. Because, those are controls are related to selected record only. if no record selected then it should not be enable. Following is my listview's selected changed event: Private Sub lv_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lv.SelectedIndexChanged If lv.SelectedItems.Count() > 0 Then ... .

XAML ComboBox SelectionChanged Fires OnLoad

半世苍凉 提交于 2020-01-13 08:36:10
问题 If I have a ComboBox that has a SelectionChanged event, it fires when I'm loading the control. So at page load I set the SelectedValue and the SelectionChanged event fires which is not what I want to happen. What is the accepted apporach to stopping this? 回答1: Two obvious solutions to this would be 1) Wait until the Loaded event of the Window/Page/UserControl which contains the ComboBox and hook up SelectionChanged there...eg in the constructor: // set the inital selected index for the combo

XAML ComboBox SelectionChanged Fires OnLoad

荒凉一梦 提交于 2020-01-13 08:35:08
问题 If I have a ComboBox that has a SelectionChanged event, it fires when I'm loading the control. So at page load I set the SelectedValue and the SelectionChanged event fires which is not what I want to happen. What is the accepted apporach to stopping this? 回答1: Two obvious solutions to this would be 1) Wait until the Loaded event of the Window/Page/UserControl which contains the ComboBox and hook up SelectionChanged there...eg in the constructor: // set the inital selected index for the combo

Virtualization and SelectionChanged event

本秂侑毒 提交于 2020-01-07 08:46:41
问题 I am using SelectionChanged event of ListBox , but it "doesn't work". Here is repro: public partial class MainWindow : Window { readonly List<Item> _items = new List<Item> { new Item(), ... // add 20 more, to have selected item outside of visible region new Item(), new Item { IsSelected = true }, new Item(), }; void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) => Debug.WriteLine($"Changed {e.AddedItems.Count}/{e.RemovedItems.Count}"); void button_Click(object sender,

wpf combobox prevent text changed

陌路散爱 提交于 2020-01-06 04:29:18
问题 is there any way to prevent wpf combobox from changing its text after selection changed? I have a custom control that derives from combobox and I want to be able to set the text manually after selection changed, additionally I cannot prevent the base.OnSelectionChanged from being invoked (this does the trick but it has to stay there as a part of requirements) 回答1: In general the IsEditable and the IsReadOnly properties of ComboBox are used to control the level to which the display Text of the

Silverlight MVVM, stop SelectionChanged triggering in response to ItemsSource reset

ぐ巨炮叔叔 提交于 2020-01-02 23:11:08
问题 I have two ComboBoxes, A & B, each bound to an Observable Collection. Each has a SelectionChanged trigger is attached which is intended to catch when the user changes a selection. The trigger passes the selection to a Command. The collections implement INotifyPropertyChanged in that, in the Setter of each, an NotifyPropertyChanged event is fired. This is needed (in the MVVM approach) to notify the UI (the View) that the ComboBox's contents have changed. The two ComboBoxes are interdependent -

WPF ListView SelectionChanged inside style does not work. EventSetter either

你。 提交于 2019-12-29 09:12:14
问题 <Style x:Key="OrderGroupTemplateStyle" TargetType="{x:Type ContentControl}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=Name.ShowDetailedInfo, UpdateSourceTrigger=PropertyChanged}" Value="False"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <Border BorderBrush="Gray" BorderThickness="2" CornerRadius="3" Margin="2"> <StackPanel Background="LightGoldenrodYellow"> <ContentControl Content="{Binding Path=.}" Style="{StaticResource MyRecordViewModelShortStyle}"/>

WPF ListView SelectionChanged inside style does not work. EventSetter either

*爱你&永不变心* 提交于 2019-12-29 09:12:11
问题 <Style x:Key="OrderGroupTemplateStyle" TargetType="{x:Type ContentControl}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=Name.ShowDetailedInfo, UpdateSourceTrigger=PropertyChanged}" Value="False"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <Border BorderBrush="Gray" BorderThickness="2" CornerRadius="3" Margin="2"> <StackPanel Background="LightGoldenrodYellow"> <ContentControl Content="{Binding Path=.}" Style="{StaticResource MyRecordViewModelShortStyle}"/>

WPF Listview SelectionChanged event

自闭症网瘾萝莉.ら 提交于 2019-12-20 12:25:52
问题 I have a ListView binding to an ItemsSource . Why is the SelectionChanged event firing on the load/databound events? I assume that it is because a 'default' items ie index 0 is selected. How can I disable this, because when selecting an item updated other sources with data. Thanks Petrus 回答1: The listView should not fire the SelectionChange if you only set the ItemsSource property. However if you bind the SelectedIndex property to a property of your dataContext object the selection will move

How can I realize SelectionChanged in MVVM ListBox Silverlight

主宰稳场 提交于 2019-12-19 03:14:35
问题 The ListBox control does not implement a Command property. I have to attach some functionality to the SelectionChanged event. Somebody knows how can I do it? Please help me 回答1: I prefer using a binding to the SelectedItem and implementing any functionality in the setting of the binding property. <ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" /> ... public class ViewModel { public IEnumerable<Item> Items { get; set; } private Item selectedItem; public Item