Can't make checked list box and listbox in same size
I can not make the DrawItem event to work on the CheckedListBox control. It's not called if the user clicks in the empty area from the right edge of the TextBlock to the right edge of the ListBox. What i want to do is to does not allow user to edit listbox or combobox items at run time. I tried to use "LOCKED" property of listbox and combobox control But it locked entire contol. ot make the DrawItem event to work on the CheckedListBox control.
Re: Can't make checked list box and listbox in same size
I suspect that you are not clicking inside of the stack panel that is why the mouse event is not firing. You might have to set the width of the stack panel. To your newly created form add from the Toolbox a ListBox named 'itemList', a TextBox named itemName and three buttons named 'cmdAdd', 'cmdRem' and 'cmdClr'.
Re: Can't make checked list box and listbox in same size
Put your stackpanel into a grid and insert an invisible rectangle under the stackpanel. You can however 'cheat' and make a regular ListBox look like a CheckedListBox. The DrawMode/DrawItem in CheckedListBox is used internally only.Set your rectangle to stretch in all directions, finally apply your eventhandler to the grid and not the stackpanel.
Re: Can't make checked list box and listbox in same size
You can however, Inherit from CheckedListBox and override the OnDrawItem method. I also tried commenting out all the stuff withen the ControlTemplate however that didn't help. Simply setting the Template seems to cause problems. This saves you having to implement the checked property of the items, which you would need to do if you inherit from ListBox or else just custom paint Listbox.