![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| Guest | WPF Lookless control that inherits ComboBox - IsEditable problem I've built a "lookless" control that inherits ComboBox. It has three dependancy properties (CountryCode, Label, and ListByName), and a ReadOnly property of DistrictList. Whenever CountryCode changes, the Label is changed, and the DistrictList is rebuilt. (eg. Country changes from CAN to USA, Label will change from Province to State, and the list contents will change from provinces to states). When the ListByName property changes, the items in the list will flip from names, to two character codes, or back again (eg. Ontario to ON, or ON to Ontario). In my Generic.xaml file, the ControlTemplate uses a dockpanel that contains a label and a combobox. I've bound the label Content property to the control Label property, and I've bound the combobox ItemSource to the control DistrictList property. So far so good... I can flip between CAN and USA, and the control flips between provinces and states. However, I also want to support a country of "Other", and when that country is chosen, the DistrictList that gets built is empty. So after building the list, I check its Count property. If it is 0, I set IsEditable to True, else I set it to False. That way, when there are no items in the list, the user can type something in, but when there are items in the list, the user can't type something in and must select something. Changing the ComboBox's editable state is the part I can't seem to get working. I have subs that fire when the CountryCode and ListByName depedancy properties change. Inside those subs they call a private method called LoadDistrictList. That is the method that fills the private member variable for the DistrictList property, and that sets IsEditable to true or false. I was ablet o get this working by creating a new dependency property called MyIsEditable (and MyIsEditableProperty). I then added IsEditable="{Binding Path=MyIsEditable,RelativeSource={RelativeSource TemplatedParent}}" to the combobox in my Generic.xaml for my control. (I also did the same for IsReadOnly.) Could someone explain why I can't use the IsEditable (and IsReadOnly) property on my control (inherited from ComboBox), directly? |
My System Specs![]() |