WPF Bug List (ordinal) and (1)--Multiple Select single ListBox

Source: Internet
Author: User
Tags xmlns

Released from. NET 3.0, the. NET Framework has successively published. NET 3.5 and. NET3.5 SP1. Two WPF-based projects were made during this period. It is true that the current WPF bug is not very small. The development of the program has caused a lot of trouble-to avoid bugs, but have to write a lot of code.

This "WPF Bug List" series will list the various issues of WPF that I've encountered in my project, and may not necessarily be a bug, but it can cause development inconvenience. More feel the first release of WPF is spot suspicion. A lot of things have not been done before the release. (As with Silverlight 1.0)

First of all, give me the simplest bug. The listbox in WPF selects the bug.

1<window x:class= "Listboxselectionbug.demowindow"
2 xmlns= ""
3 xmlns:x= "
4 xmlns:sys=" Clr-namespace:system;assembly=mscorlib "
5 xmlns:forms=" clr-namespace:system.windows.forms;assembly= System.Windows.Forms "
6 title=" ListBox Selection Bug Demo "height=" width= "+"
7 <dockpanel margin= " "" "
8 <label content=" casually point, they should be all the radio Oh. "
9 dockpanel.dock=" Top "/>
<groupbox header=" WPF ListBox "
One dockpanel.dock=" Top " padding= "9" margin= "0,0,0,12"
<listbox selectionmode= "single"
<sys:s        Tring>a string Value</sys:string>
<sys:string>a string value</sys:string>
16 <sys:string>a String value</sys:string>
</listbox>
</groupbox>
&L T GroupBox header= "Forms ListBox" padding= "9"
<windowsformshost>
<forms:listbox&Gt            
<forms:listbox.items>
<sys:string>a string</sys:string>
24          <sys:string>a string</sys:string>
<sys:string>a string</sys:string>
26    </forms:listbox.items>
</forms:listbox>
</windowsformshost>
29 </groupbox>
</dockpanel>
31</window>

The above source code lists both the WPF ListBox and the WinForm ListBox as comparisons. Note that in the WPF ListBox, it is deliberately labeled as a single select list box. But it turned out to be this way.

Figure 1. WPF ListBox Selection Bugs

is to place several string values directly in the listbox. As a result, the WPF ListBox treats a string with the same string as the one, and becomes a multiselection listbox.

From. NET 3.0 to the. NET 3.5 SP1, the bug still lies in WPF. Do not know whether Microsoft does not think that this is a bug?

PS: Please do not suggest putting ListBoxItem in the listbox to avoid this problem.

In the next few, you will continue to expose some of the WPF bugs or inconveniences (basically all the controls are available.) , we are more than welcome to add to the bug that I found, after all, a person's insight is limited. Hope to give you some hints.

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.