Поэтому я пошел Вернувшись к основам, я создал небольшой тестовый проект надстройки VSTO Outlook 2013, и там происходит то же самое. Событие SelectionChange в проводнике вызывается дважды.
Код: Выделить всё
public partial class ThisAddIn
{
private Explorer _activeExplorer;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
_activeExplorer = Application.Explorers[1];
_activeExplorer.SelectionChange += _activeExplorer_SelectionChange;
}
private void _activeExplorer_SelectionChange()
{
System.Diagnostics.Debug.WriteLine("_activeExplorer_SelectionChange : " + DateTime.Now.ToString());
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
Есть идеи почему событие SelectionChange срабатывает дважды?
И что я могу сделать, чтобы оно сработало только один раз (кроме написания собственного кода, чтобы проверить, изменился ли выбор)?
Подробнее здесь: https://stackoverflow.com/questions/279 ... onchange-e