The WPF bug list (--checkbox) has different behavior under different topics

Source: Internet
Author: User

We all know that window has multiple themes (Theme). Under normal circumstances, obviously we would like to have different themes, the behavior of our application will not change. Or, we don't want to write specific logic for the control for a particular topic. Unfortunately, there are problems with some of the controls in the. NET framework, so that we have to deal specifically with the control under specific topics when we use it.

Let me give you an example. Putting a checkbox in a ListBox, forming a checkboxlist should be a more common application. In theory, the easiest way to do this in WPF is to put a checkbox in the ItemTemplate of the ListBox or in the Itemcontainerstyle.

But in fact, when you do this simple CheckBoxList, you will encounter one problem after another. First of all, to reiterate the intent of the text, fearing that they did not explain the white misleading.

This article is not a discussion

CheckBoxList

The blue bar in question, but in the discussion checkbox

The problem of different behaviors under different topics. CheckBoxList

is just an example.

Take a look at the effect chart first.

Figure 1. A checkbox under two themes

In the above illustration, the left side is a checkbox under the classic theme. On the right is the CheckBox under the XP default Luna theme.

Question 1. The ischecked state of the checkbox is out of sync with the isselected state of the ListBoxItem. If you want to keep the blue bar selected, then it is easier to do, the two attributes binding together on it. If you don't want the blue bar that was selected, it's a little bit more complicated. There are many solutions, so don't go into it. In the sample program, the problem is not resolved in order to reduce interference.

Question 2. When the item on the checkbox is selected, it is blue. The text in the checkbox is black, which is inconsistent with the default color behavior of the ListBoxItem. In order for a checkbox to be white when selected, it is not difficult to write a binding. This is not a problem at all, but to solve this problem, the following problems are the main problem. (Of course, if you hide the blue bar, there's no problem.) )

Question 3. This is the main topic of this article, look at the following pictures to know. We do the same thing on both sides of the CheckBoxList. First come to the right.

Figure 2. Select the Last checkbox

Figure 3. Click the blank on the side of the checkbox just now to select it

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.