c# - Button that expands ComboBox causing infinite loop -
i have button on top of combobox, received element other developer , cannot change drastically. need happen when hover on button combobox open, when leave close. when click button trigger function. problem when hover on button combobox focus , stuck in infinite loop of open close (maybe there else wrong). not work.
<grid margin="10,0,10,0" grid.column="1"> <grid.columndefinitions> <columndefinition width="85*"/> <columndefinition width="15*"/> </grid.columndefinitions> <combobox height="30" name="combo2" style="{staticresource categorycombobox}" selectionchanged="combobox_selectionchanged2" 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> <button mouseenter="mouseenter2" mouseleave="mouseleave2" name="menu_btn2" click="gotomenu" style="{staticresource categorybutton}" grid.column="0" content="category name 2" margin="20,0,0,0" fontsize="16" fontfamily="pack://application:,,,/fonts/#univers lt std 57 cn" /> </grid>
code:
private void mouseenter2(object sender, routedeventargs e) { combo2.isdropdownopen = true; } private void mouseleave2(object sender, routedeventargs e) { combo2.isdropdownopen = false; }
my first idea unsubscribe mouseenter2-event @ moment enter button. in mouseleave2-event have subscribe again mouseenter2. maybe works you
to unsubscribe mouseenter2-event have to:
button.mouseenter -= mouseenter2;
Comments
Post a Comment