SilverlightShow: Silverlight Custom ComboBox Comments http://www.silverlightshow.net/ Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples SilverlightShow.net http://www.rssboard.org/rss-specification Argotic Syndication Framework 2008.0.2.0, http://www.codeplex.com/Argotic en-US estoychev@completit.com (Emil Stoychev) Re: Silverlight Custom ComboBox I just wonder if i<span style="color: #3681cc;">t's possible to prevent dropdown when click every where on the combobox but togglebutton?</span> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment8515 CongTuBot http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Sun, 30 Sep 2012 12:39:05 GMT Re: Silverlight Custom ComboBox <p>thank u for the wonderfull control......but i found that combobox.selectedindex = -1 does not work....cud u advise me how to do that.</p> <p> </p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment8141 yoosufshanij http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Sat, 09 Jun 2012 11:26:24 GMT Re: Silverlight Custom ComboBox I have an user control (like TreeView), and my purpose is adding this control as a content of Combo box, can you give me an example? http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment7229 EnKiu.Minh http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 17 Nov 2011 11:48:29 GMT Re: Silverlight Custom ComboBox I have an user control (like TreeView), and my purpose is adding this control as a content of Combo box, can you give me an example? http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment7228 EnKiu.Minh http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 17 Nov 2011 11:46:58 GMT Re: Silverlight Custom ComboBox <p>hi</p> <p>Yes it works in 4 and 5</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment7211 Gigatron http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 15 Nov 2011 15:07:56 GMT Re: Silverlight Custom ComboBox It is good but can we use this in silverlight 4.0 http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment7210 durga http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 15 Nov 2011 14:56:54 GMT Re: Silverlight Custom ComboBox <p><em>this is a workaround to fix the width of the popup</em></p> <pre style="font-family: consolas; background: white; color: black; font-size: 13px;"> <span style="color: blue;">protected</span> <span style="color: blue;">override</span> <span style="color: #2b91af;">Size</span> ArrangeOverride(<span style="color: #2b91af;">Size</span> finalSize)         {             <span style="color: blue;">if</span> (popup != <span style="color: blue;">null</span> && validationElement != <span style="color: blue;">null</span>)             {                 <span style="color: #2b91af;">Grid</span> validationElementGrid = validationElement.GetVisualDescendants().OfType<<span style="color: #2b91af;">Grid</span>>().FirstOrDefault();                 <span style="color: blue;">double</span> finalWidth = validationElementGrid.Width + validationElementGrid.Margin.Left + validationElementGrid.Margin.Right;                 contentBorder = popup.Child <span style="color: blue;">as</span> <span style="color: #2b91af;">Border</span>;                 <span style="color: blue;">if</span> (contentBorder == <span style="color: blue;">null</span>)                     <span style="color: blue;">return</span> <span style="color: blue;">base</span>.ArrangeOverride(finalSize);                 contentBorder.Width = finalSize.Width - finalWidth;                             }             <span style="color: blue;">return</span> <span style="color: blue;">base</span>.ArrangeOverride(finalSize);         }</pre> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment7045 Gigatron http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Wed, 26 Oct 2011 08:06:22 GMT Re: Silverlight Custom ComboBox <p>i found behaviour error -  </p> <p>when i use this comboBox inside Expander- if i collapse expander when ComboBox showing Popup List, this Popup will still exist  on the screen.  </p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment7043 xidius http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 25 Oct 2011 18:48:14 GMT Re: Silverlight Custom ComboBox <p>Hi </p> <p>I'm using SL5 (tried in 4 as well) </p> <p>In the property of the combo box there is no <span style="color: #ff0000; font-family: consolas, 'courier new', courier, monospace; font-size: 11px; line-height: 16px; white-space: pre; background-color: #ffffff;">DropDownWidth</span></p> <p><span style="font-family: consolas, 'courier new', courier, monospace; color: #ff0000; font-size: 11px; line-height: 16px; white-space: pre;">whats am i doing wrong?</span></p> <p><span style="font-family: consolas, 'courier new', courier, monospace; color: #ff0000; font-size: 11px; line-height: 16px; white-space: pre;"><br /> </span></p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment6526 Gigatron http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 15 Sep 2011 16:02:54 GMT Full screen mode Control doesn't work correctly in full screen mode !? http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment6075 Sergio http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 05 May 2011 14:05:01 GMT Full screen mode Control doesn't work correctly in full screen mode !? http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment6074 Sergio http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 05 May 2011 14:04:03 GMT Updated but still useful As was said above this article is a bit outdated now, but I could still learn a lot from it. I plan on adapting this to use on my <a href="http://www.withvb.net/">VB.NET Tutorials</a> site. Its nice to have another developer explain things so well. http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment5967 Colin P http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Fri, 22 Apr 2011 15:08:31 GMT RE: Silverlight Custom ComboBox Excellent! Thank you for posting! http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment5767 Eric Carlson http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 24 Mar 2011 17:58:35 GMT RE: Silverlight Custom ComboBox <p>One of the best code i ever found ...keep it</p> <p>Thanks for Help!!</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment5453 Anil Maurya http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 08 Feb 2011 12:59:44 GMT RE: Silverlight Custom ComboBox <em><span style="font-size: 11pt; line-height: 115%; font-family: calibri, sans-serif;">The article has been updated to the latest version of Silverlight and Visual Studio.</span></em> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment5373 lnikolov http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Mon, 24 Jan 2011 09:58:57 GMT RE: Silverlight ComboBox <p>Be warned this doesn't compile in Silverlight 4, as the Microsoft Silverlight team have actually changed the virtual method signatures of TypeConverter (plus a whole host of other compile errors).</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment4385 disgruntledsilverlightdev http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Wed, 01 Sep 2010 13:14:34 GMT RE: Silverlight ComboBox <p>When you have a List<DateTime> that you bind to a ComboBox by setting the ItemsSource how can you format the items?</p> <p>Thanks!</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment4159 Bond http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 05 Aug 2010 17:38:47 GMT Silverlight ComboBox <p><strong>how to display text in combobox in silverlight</strong></p> <p>you can display selected value of combobox into textbox in silverlight</p> <p>TextBox1.Text= (cmbApplicationStatus.SelectedItem as ComboBoxItem).Content.ToString();</p> <p>here, cmbApplicationStatus is Name of your combobox</p> <p>thank you</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment3851 Vikas http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 22 Jun 2010 10:09:53 GMT RE: Silverlight ComboBox <p>hello sir,</p> <p>can u tell me how to remove a selected item from downdown list in silverlght.bcz i have one drown down box and it has 10 items so if i select 4th entry so 4th item should automatically deleted. it cant give the 4th item.</p> <p>so please help me... Thanking you.</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment3740 Kamlesh http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 08 Jun 2010 15:11:25 GMT Silverlight ComboBox updated to SL3 We updated the ComboBox to Silverlight 3. You can find the article, demo and code at <a href="http://www.studio6software.com/blog">http://www.studio6software.com/blog</a>. <p>Regards,<br /> Doug</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment2748 dougblackmore http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Wed, 09 Dec 2009 04:48:56 GMT RE: Silverlight ComboBox I want to have a default "ANY" value in my combo box with a value of null. <p>That way i know if no item has been selected when i click search or whatever.</p> <p>It seems to be ridiculously weak that once i've selected an item in a combobox i can't unselect it.</p> <p> </p> <p> </p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment2687 silverlame http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Wed, 18 Nov 2009 05:36:44 GMT RE: Silverlight ComboBox <p>Hi Doug, I am looking forward to the SL3 version! </p> <p>For what I see now: great work!</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment2616 Friso http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Sun, 01 Nov 2009 13:08:34 GMT RE: Silverlight ComboBox We're updating the ComboBox to work with SL3. I'll post here when it's ready (very shortly now).<br /> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment2579 dougblackmore http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 27 Oct 2009 20:18:29 GMT RE: Silverlight ComboBox This looks pretty good, but I have trouble getting it running in SL3.  Does anyone have a demo compiled with SL3? http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment2578 ArnieB http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 27 Oct 2009 19:20:57 GMT RE: Silverlight ComboBox Great work. Developing a combobox can be boring but is necessary for most applications. Thank you so much for writing up this great tutorial on how to do it. Keep them coming - us developers can use all the help we can get. <p>Thanks, Matt (<a href="http://www.vb6.us/" title="VB6">Visual Basic 6</a>)</p> <br /> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment2370 Matt http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Fri, 18 Sep 2009 17:32:10 GMT RE: Silverlight ComboBox Ive added a combobox which has the years of graduation from 1999 to 2009, when the user chooses lets say 1999 from the combobox, it will automatically concatenate file name to 1999_fileName.jpg. <p>any idea how i can do that?</p> <img alt="" src="file:///C:/DOCUME%7E1/user/LOCALS%7E1/Temp/moz-screenshot.png" /> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment2283 Aki http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Wed, 26 Aug 2009 06:50:40 GMT RE: Silverlight ComboBox <p>Hi,</p> <p>once you have databinded your combobox:</p> <p>cboProvinces3.ItemSource=Provinces;</p> <p>How can you add a row, like "Select a province" at the top ?</p> <p>I've tried something like:</p> <p>cboProvinces3.InsertAt(0, "[Select]");</p> <p> </p> <p>but that gives me a System.InvalidOperationException: Operation not supported on read-only collection.</p> <p>error.</p> <p> </p> <p>Any thoughts?</p> <p> </p> <p>thanks,</p> <p>Seb</p> <p> </p> <p> </p> <p> </p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment1781 seb http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 02 Jul 2009 12:55:20 GMT RE: Silverlight ComboBox Need to update the source as it is currently not working for SL2....may want to take a step forward and look at porting this to SL3 since it is in beta.  But overall its information on how to utilize the drop down box into SL. http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment1593 goldbishop http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Sat, 23 May 2009 16:08:27 GMT RE: Silverlight with express edition Is silverlight a freeware tools? Can I use silverlight with express edition? http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment1362 Jen http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Mon, 30 Mar 2009 21:39:02 GMT RE: Silverlight ComboBox <p>Hello when I try to use the <span style="color: rgb(255,0,0)">DropDownWidth</span><span style="color: rgb(0,0,255)">="300"</span>  property, the compiler fails, I'm using Silverlight 2, Silverlight tools 2 SP1, do you know whats is wrong here?</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment1023 al011757@hotmail.com http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Sat, 07 Feb 2009 13:05:53 GMT RE: Silverlight ComboBox <p>Seems like Silverlight 2.0 has caused some issues with the control.  Has anyone been successful in implementing in 2.0?</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment861 Quest4Denali http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Sat, 20 Dec 2008 12:22:38 GMT RE: Silverlight ComboBox <p>Mr. doug I am using the combo box but one prob i am facing that after selecting item from combobox i can't change the itemsource . If I try to do that the screen becomes blank. or system crashes. No error message showing. But if i don't select any item then i can change the itemsource.</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment563 Aref http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Sun, 19 Oct 2008 21:05:19 GMT RE: Silverlight ComboBox <p>sorry, forgot one button</p> <p>when "Save" button press, to get ComboBox's index, and TextBox's value, and that row data</p> <p><Button x:name="Save" Content="Save" Width="80" Height="Auto" Click="SaveClick" /></p> <p><my:DataGrid x:Name="myDataGrid" Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ><br />     <my:DataGrid.Columns><br />         <my:DataGridTextColumn Header="ID" DisplayMemberBinding="{Binding ID}" /><br />         <my:DataGridTextColumn Header="Ages" DisplayMemberBinding="{Binding Ages}" /></p> <p>        <my:DataGridTemplateColumn Header="" ><br />             <my:DataGridTemplateColumn.CellTemplate><br />                 <DataTemplate><br />                     <StackPanel Width="Auto" Height="60" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Orientation="Horizontal" Background="#FFDBF7E8" ><br />                         <br />                         <TextBox Width="80" Height="25" FontFamily="Arial" FontSize="12" Margin="8" TextChanged="TextChange" /></p> <p>                        <controls:ComboBox FontFamily="Arial" FontSize="12" Width="100" Margin="2" VerticalAlignment="Center" SelectedIndex="1"<br />                                            SelectedItem="{Binding Food, Mode=TwoWay}"<br />                                            ItemsSource="{Binding Food, Source={StaticResource food}}" /><br />                     </StackPanel><br />                 </DataTemplate><br />             </my:DataGridTemplateColumn.CellTemplate><br />         </my:DataGridTemplateColumn></p> <p>    </my:DataGrid.Columns><br /> </my:DataGrid></p> <p>Thanks very much !!</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment518 oneone http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 07 Oct 2008 23:19:23 GMT RE: Silverlight ComboBox <p>Hi !</p> <p>could you teach me how to get the row data ?</p> <p>my code like this, i want when TextBox's text change, then get ComboBox's value, and that row's data</p> <p><my:DataGrid x:Name="myDataGrid" Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ><br />     <my:DataGrid.Columns><br />         <my:DataGridTextColumn Header="ID" DisplayMemberBinding="{Binding ID}" /><br />         <my:DataGridTextColumn Header="Ages" DisplayMemberBinding="{Binding Ages}" /></p> <p>        <my:DataGridTemplateColumn Header="" ><br />             <my:DataGridTemplateColumn.CellTemplate><br />                 <DataTemplate><br />                     <StackPanel Width="Auto" Height="60" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Orientation="Horizontal" Background="#FFDBF7E8" ><br />                         <br />                         <TextBox Width="80" Height="25" FontFamily="Arial" FontSize="12" Margin="8" TextChanged="RunBetChange" /></p> <p>                        <controls:ComboBox FontFamily="Arial" FontSize="12" Width="100" Margin="2" VerticalAlignment="Center" SelectedIndex="1"<br />                                            SelectedItem="{Binding Food, Mode=TwoWay}"<br />                                            ItemsSource="{Binding Food, Source={StaticResource food}}" /><br />                     </StackPanel><br />                 </DataTemplate><br />             </my:DataGridTemplateColumn.CellTemplate><br />         </my:DataGridTemplateColumn></p> <p>    </my:DataGrid.Columns><br /> </my:DataGrid></p> <p>thanks for your help !</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment516 oneone http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 07 Oct 2008 22:56:48 GMT RE: Silverlight ComboBox <p>Doug thanks for the prompt reply..To all the readers silverlight 2.0 beta is moved to RC and Msft have included combox box control..i havent used it but hoping i will be bug free..</p> <p>Alok Varia</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment491 Alok Varia http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 02 Oct 2008 07:48:06 GMT RE: Silverlight ComboBox <p>perfect  !!</p> <p>thanks !! </p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment488 oneone http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Wed, 01 Oct 2008 20:04:41 GMT RE: Silverlight ComboBox <p>Sure, try the following:</p> <p>Page.xaml:</p> <p><UserControl x:Class="ComboBoxDemo.Page"<br />     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <br />     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" <br />     xmlns:controls="clr-namespace:WorkSight.Controls" <br />     xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" <br />     xmlns:ComboBoxDemo="clr-namespace:ComboBoxDemo" <br />     Width="Auto" Height="300"><br /> <br />     <UserControl.Resources><br />         <ComboBoxDemo:ProvinceLookup x:Key="provinceLookup"/><br />     </UserControl.Resources><br /> <br />     <StackPanel x:Name="LayoutRoot" Background="White"><br />         <data:DataGrid x:Name="dataGrid" Width="Auto" Height="300" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="Visible" AutoGenerateColumns="False" ><br />             <data:DataGrid.Columns><br />                 <data:DataGridTextColumn Header="FullName" DisplayMemberBinding="{Binding Description}" /><br />                 <data:DataGridTextColumn Header="Abbreviation" DisplayMemberBinding="{Binding Abbreviation}" /><br /> <br />                 <data:DataGridTemplateColumn Header="Description" ><br />                     <data:DataGridTemplateColumn.CellTemplate><br />                         <DataTemplate><br />                             <controls:ComboBox x:Name="combo" <br />                                                FontFamily="Arial" <br />                                                FontSize="12" <br />                                                Width="250" <br />                                                Margin="2" <br />                                                VerticalAlignment="Center" <br />                                                SelectedItem="{Binding FullName, Mode=TwoWay}" <br />                                                ItemsSource="{Binding Provinces, Source={StaticResource provinceLookup}}" <br />                             /><br />                         </DataTemplate><br />                     </data:DataGridTemplateColumn.CellTemplate><br />                 </data:DataGridTemplateColumn><br />             </data:DataGrid.Columns><br />         </data:DataGrid><br />     </StackPanel><br /> </UserControl><br />  </p> <p>Page.xaml.cs (use the existing Province class):</p> <p>    public partial class Page<br />     {<br />         public Page()<br />         {<br />             InitializeComponent();<br /> <br />             IList<Province> provinces = new List<Province>();<br />             provinces.Add(new Province("British Columbia", "BC", new DateTime(1871, 7, 20)));<br />             provinces.Add(new Province("Alberta", "AB", new DateTime(1905, 9, 1)));<br />             provinces.Add(new Province("Saskatchewan", "SK", new DateTime(1905, 9, 1)));<br />             provinces.Add(new Province("Manitoba", "MB", new DateTime(1870, 7, 15)));<br />             provinces.Add(new Province("Ontario", "ON", new DateTime(1867, 7, 1)));<br />             provinces.Add(new Province("Quebec", "QC", new DateTime(1867, 7, 1)));<br />             provinces.Add(new Province("Newfoundland", "NL", new DateTime(1949, 3, 31)));<br />             provinces.Add(new Province("Prince Edward Island", "PE", new DateTime(1873, 7, 1)));<br />             provinces.Add(new Province("New Brunswick", "NB", new DateTime(1867, 7, 1)));<br />             provinces.Add(new Province("Nova Scotia", "NS", new DateTime(1867, 7, 1)));<br />             provinces.Add(new Province("Nunavut", "NU", new DateTime(1999, 4, 1)));<br />             provinces.Add(new Province("Yukon", "YT", new DateTime(1898, 6, 13)));<br />             provinces.Add(new Province("Northwest Territories", "NT", new DateTime(1870, 7, 15)));<br />             this.dataGrid.ItemsSource = provinces;<br />         }<br />     }<br /> <br />     public class ProvinceLookup<br />     {<br />         public IList<string> Provinces<br />         {<br />             get<br />             {<br />                 IList<string> provinces = new[] {<br />                                           "British Columbia", "Alberta", "Saskatchewan", "Manitoba", "Ontario", "Quebec",<br />                                           "Newfoundland", "Prince Edward Island", "New Brunswick",<br />                                           "Nova Scotia", "Nunavut", "Yukon", "Northwest Territories"<br />                                       };<br />                 return provinces;<br />             }<br />         }<br />     }<br />  </p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment486 Doug http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Wed, 01 Oct 2008 07:21:02 GMT RE: Silverlight ComboBox <p>can it put into the datagrid ?</p> <p>like this</p> <p>            <my:DataGrid x:Name="myDataGrid" Width="500" Height="500" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="Visible" ><br />                 <my:DataGrid.Columns><br />                     <my:DataGridTextColumn Header="FullName" DisplayMemberBinding="{Binding FullName}" /><br />                     <my:DataGridTextColumn Header="Abbreviation" DisplayMemberBinding="{Binding Abbreviation}" /><br /> <br />                     <my:DataGridTemplateColumn ><br />                         <my:DataGridTemplateColumn.CellTemplate><br />                             <DataTemplate><br />                                 <controls:ComboBox x:Name="combo" FontFamily="Arial" FontSize="12" Width="250" Margin="2" VerticalAlignment="Center" /><br />                             </DataTemplate><br />                         </my:DataGridTemplateColumn.CellTemplate><br />                     </my:DataGridTemplateColumn><br /> <br />                 </my:DataGrid.Columns><br />             </my:DataGrid></p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment482 oneone http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Tue, 30 Sep 2008 23:48:10 GMT RE: Silverlight ComboBox <p>Alok,</p> <p>In the ComboBox::OnKeyDownInternal method, add the following inside the switch statement:</p> <p>   case Key.Tab:<br />       this._applyFilter = false;<br />       return false;<br />  </p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment459 Doug http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Sat, 27 Sep 2008 08:37:01 GMT RE: Silverlight ComboBox <p>I just did testing on your sample code same issue l00ks like a bug....any quick fix to it??</p> <p>Thanks in advance..</p> <p>Alok Varia</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment454 Alok Varia http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Fri, 26 Sep 2008 07:29:35 GMT RE: Silverlight ComboBox <p>Hi,</p> <p>First its very good control and easy to implement..i have facing one issue...when i select something and tab out using tab key it removes all the selection choice apart from what i have selected...any ideas why??</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment453 Alok Varia http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Fri, 26 Sep 2008 07:26:17 GMT RE: Silverlight ComboBox <p>Mark,</p> <p>In generic.xaml, it's possible you may not have made the appropriate change on line 159 once you changed the namespace. The line currently reads:</p> <p>     <Image Stretch="None" Source="/ComboBoxDemo;Component/ComboBox/downarrow.png" /></p> <p>You can either change the namespace, or change the line to the following:</p> <p>     <Image Stretch="None" Source="ComboBox/downarrow.png" /></p> <p>The latest source on our website has this fix + some others:</p> <p>    http://worksightblog.com/?p=72</p> <p>Let me know if this helps.</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment441 dougblackmore http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 25 Sep 2008 09:08:22 GMT RE: Silverlight ComboBox <p>Hi,</p> <p>I've added the 4 files to my own control library, changed the namespaces etc.  to match in with my controls but when I add a combobox to my project I get an error message saying "Value does not fall within the expected range"  Any Ideas?</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment439 Mark Aitken http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 25 Sep 2008 06:44:54 GMT RE: Silverlight ComboBox <p>Sorry henrik, you're not giving me a lot to go on here. From what I understand, you've copied the ComboBox.cs, ComboBoxItem.cs, downarrow.png and generic.xaml to your SilverLight.Controls.dll project and kept the WorkSight.Control namespace. In VS2008, you're getting a 'missing SilverLight.Controls reference' error message?</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment437 dougblackmore http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Wed, 24 Sep 2008 12:28:30 GMT RE: Silverlight ComboBox <p>The silverlight assembly I created. I called it Silverlight.Controls.dll maintaining your Namespace.</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment435 henrik http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Wed, 24 Sep 2008 07:59:21 GMT RE: Silverlight ComboBox <p>No, I haven't seen that one. Which assembly does it say you're missing?</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment425 Doug http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Sun, 21 Sep 2008 07:43:51 GMT RE: Silverlight ComboBox <p>Looks great!</p> <p>I've tried to put just the combobox code files, generic.xaml and the arrow-image into a silverlight library, to reference the stuff in my silverlight project. Works during runtime, but does not work in the XAML editor in VS2008 - it tells me I'm missing an assembly reference - which i do not.</p> <p>Have you experienced this one?</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment424 henrik http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Sun, 21 Sep 2008 04:09:21 GMT RE: Silverlight ComboBox <p>I overwrite the Province.Equals() method and Combobox.GetComboBoxItemForObject(), now <br /> in c# <br /> cboProvinces3.SelectedItem=new Province("Alberta",                        "AB", new DateTime(1905, 9, 1));<br /> works well, but I still do not know how to set the SelectedItem Property in xaml directlly.</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment385 soundbox http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 11 Sep 2008 22:43:48 GMT RE: Silverlight ComboBox <p>Thank you for your reply. <br /> Sorry for my poor description, it is not so clear that I make you mistake...<br /> Define cboProvinces3 as follow, I want to display <strong>"Alberta"</strong> the first time cboProvinces3 is shown.<br /> The problem is:<br />  <strong>"Alberta" is dynamic</strong>(<strong> </strong>eg. binding to a variable assuming its value be unique in the ItemSource )<br /> in another word, some comboboxes  having the same ItemSource as cboProvinces3  have different   <strong>"Alberta" </strong>to be the "default SelectedItem"<br /> Hope it is clear enough.</p> <p>xaml</p> <p><StackPanel Orientation="Horizontal"><br />             <controls:ComboBox x:Name="cboProvinces3" Width="150" DropDownWidth="Auto" Margin="10" /><br />             <TextBlock Text="Populated from code; DropDownWidth='Auto' (dropdown wider than combo box)" VerticalAlignment="Center" Margin="5"  <br /> <em>DisplayMemberPath="FullName"<br /> </em><strong>SelectedItem="Alberta"</strong><br /> /><br /> </StackPanel></p> <p>c#</p> <p>IList<Province> Provinces = new List<Province>();<br />             Provinces.Add(new Province("British Columbia",      "BC", new DateTime(1871, 7, 20)));<br />             Provinces.Add(new Province("Alberta",                        "AB", new DateTime(1905, 9, 1)));<br />             Provinces.Add(new Province("Saskatchewan",          "SK", new DateTime(1905, 9, 1)));<br />             Provinces.Add(new Province("Manitoba",                    "MB", new DateTime(1870, 7, 15)));<br /> cboProvinces3.ItemSource=Provinces;</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment384 soundbox http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 11 Sep 2008 21:36:14 GMT RE: Silverlight ComboBox <p>Eugen,</p> <p>We did handle the case where focus moves to another control (in the ComboBox::LostFocus event). What is not handled is the case where a click is done on the main Silverlight surface (the 'background').</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment383 dougblackmore http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 11 Sep 2008 19:06:06 GMT RE: Silverlight ComboBox <p>soundbox,</p> <p>To set the default selection via xaml, just set the IsSelected property on the ComboBoxItem (IsSelected="True")</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment382 dougblackmore http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 11 Sep 2008 18:59:14 GMT RE: Silverlight ComboBox <p>Eugen,</p> <p>You're right - we did handle the 'press ESC to close' and the 'click on another combo to close and already-open-combobox' scenarios. I'll take a look.</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment381 dougblackmore http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 11 Sep 2008 18:52:09 GMT RE: Silverlight ComboBox <p>sorry, it should be  "mouse-leave(to set timer on)" </p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment379 soundbox http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 11 Sep 2008 16:07:29 GMT RE: Silverlight ComboBox <p>great job</p> <p>how to set the default selecteditem using xaml?</p> <p>to collapse the expanded combobox, add a timer to combobox class,   let all the child control have two event-handerler, mouse-enter( to set timer off) and mouse-leave(to set timer off),  then  the timer will do what you wish</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment378 soundbox http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 11 Sep 2008 16:05:40 GMT RE: Silverlight ComboBox <p>Looks very good indeed.</p> <p>However one issue you didn't solve, when combobox is expanded and you click somewhere else on the Silverlight screen it shall hide automatically.</p> http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx#comment377 Eugen http://www.silverlightshow.net/items/Silverlight-ComboBox.aspx Thu, 11 Sep 2008 12:45:10 GMT