WPF的SelectionChanged以相同的值 [英] WPF SelectionChanged to same value

查看:202
本文介绍了WPF的SelectionChanged以相同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ComboBox项使用的SelectionChanged,但是当我选择同一项目再次的SelectionChanged功能不火,我需要它这样做。我怎么能告诉它火没有母校女巫选择我做的。

 私人无效ComboBox_SelectionChanged4(对象发件人,SelectionChangedEventArgs E)
{

//做一些东西

}

XAML:

 <组合框高度=30NAME =Combo4风格={StaticResource的CategoryComboBox} 的SelectionChanged =ComboBox_SelectionChanged4Grid.ColumnSpan =2Grid.Column =0> 
< ComboBoxItem CONTENT =组合框项目1(例)/>
< ComboBoxItem CONTENT =组合框项目2(例)/>
< ComboBoxItem CONTENT =组合框项目3(例)/>
< ComboBoxItem CONTENT =组合框项目4(例)/>
< /组合框>



添加项目:

 的for(int i = 0; I< Pr4.Count();我++)
{
ComboBoxItem项目=新ComboBoxItem();
item.Content = Pr4可用[I]
Combo4.Items.Add(项目);

}


解决方案

我用DropDownClosed,感谢为 - 克莱门斯


I am using SelectionChanged in ComboBox item, but when I select the same item again the SelectionChanged function does not fire and I need it to do so. How can I tell it to fire no mater witch selection I do.

private void ComboBox_SelectionChanged4(object sender, SelectionChangedEventArgs e)
    {

      //do some stuff

    }

XAML:

<ComboBox   Height="30" Name="Combo4" Style="{StaticResource CategoryComboBox}"   SelectionChanged="ComboBox_SelectionChanged4" Grid.ColumnSpan="2"  Grid.Column="0">
            <ComboBoxItem Content="ComboBox Item 1 (Example)" />
            <ComboBoxItem Content="ComboBox Item 2 (Example)" />
            <ComboBoxItem Content="ComboBox Item 3 (Example)" />
            <ComboBoxItem Content="ComboBox Item 4 (Example)" />
        </ComboBox>

Adding items:

for (int i = 0; i < Pr4.Count(); i++)
        {
            ComboBoxItem item = new ComboBoxItem();
            item.Content = Pr4[i];
            Combo4.Items.Add(item);

        }

解决方案

I used DropDownClosed, thank to - Clemens

这篇关于WPF的SelectionChanged以相同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆