I'm writing a custom checkable ListBox and the items must be checked when an item is selected. The easiest approach I could come up with is to increase the CheckBox height/width (size) to cover the whole ListBoxItem area, however I couldn't manage to vertically align the square and its text, eg:
The red text is somewhat the desired alignment, given its whole area (blue rectangle). What's necessary to achieve this?
For a complete explanation, keep on reading. My current control looks like bellow:
Some have pointed out to define a custom ListBox.ItemContainerStyle
and having a setter to the IsSelected
property to the same as the CheckBox bound property, eg:
<Setter Property="IsSelected" Value="{Binding SomeBooleanObjectProperty, Mode=TwoWay}" />
This is NOT what I want as this will keep items selected whether the SomeBooleanObjectProperty
is true.
The custom control code was omitted due to not being related to this question. What I need is a custom sizeable vertically alignable CheckBox, independently whether it is going to be used in.
Aucun commentaire:
Enregistrer un commentaire