.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Make an item as Non Selectable in WPF - ListBox

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :WPF
Hi All,How to make a list item as non selectable in WPF Listbox?I have a listbox with five items (Normal single column text).(Doesn't have checkbox)My requirement is the user should not  to make Select/Focus the 1st and 4th item in ListBox. (Because that is header of following items)Any suggession/solution?ByRamesh.p Yes! We can!!

View Complete Post

More Related Resource Links

How can I make the listbox scroll to the selected item

Hi All, I have a textbox that searches the listbox below it and selects the text that I types in the textbox. Now although the item is selected in the listbox I have to scroll to the end to see if the item is selected ornot IS there a way that I can make the list box scroll to the selected item?    

radiobutton list item make visible true or false in javascript

in my project i have used one radiobuttonlist according different user login , i want to make one of radiobuttonlist item visible true or false..   please help me to solve this issue.   thanks in advance.  

Get bounding rectangle of a listbox item

Hi everyone, I can add a String or a ListBoxItem into Listbox. When item of Listbox is a ListBoxItem , I can get ListBoxItem 's rectangle by calling "ListBoxItem.PointToScreen(point)". But I can not get rectangle of an item if this item is a String . Any help would be appreciated!

Is that possible to make one of the Listboxitems to be not selectable?

I generate listbox items from xml. I need one of the items to be not selectable? Is that possible to achieve it coding only in XAML? Thank you in advance.

How to make context menu as non selectable when the usercontrol is active

I am having a context menu displayed when i right click on a node of a treeview. Suppose my treeview is as follows Root |->some.txt |-> Child(For some.txt) |-> Child1(child for Child) If i right click on Child1 i will have an option as AddNew. If the user selects i will show a user control form for the user displayed in a panel. What i need is if the user selects the option as Child1 and if the user control is active and when the user again right clicks

auto-scrolling to the selected item in a listbox



I have a listbox which is populated with items at Page_Load and has 5 items visible at a time.  Then there is a textbox where the user types some characters. On keyup event of the textbox  my code searches the listbox for the entered value and selects the item closest to the entered value. However the selected item appears as the 5th item in the listbox. I want it to be the 1st item displayed.

Any ideas ??


The selected item in my listbox is always the previous item


It's easier if you see the code but I'll give you the specific problem. My listbox is set to contain a grid format and each listboxitem has a ListBoxItem.PreviewMouseLeftButtonDown event. The problem is, the selected item is always set to the previous item.

Here is what happens in steps:


1. My image loads up

2. I click a button to generate a grid overlay of 32x32 cells over the image, each a listboxitem in a cell of that overlay

3. I click on a cell 

4. OnSelected method fires (each listboxitem is tied to this handler through the ListBoxItem.PreviewMouseLeftButtonDown event)

5. The SelectedItem is null when I click on cell (0,0)

6. If I click on cell (0,1), the ListBoxItem.PreviewMouseLeftButtonDown event fires but now the SelectedItem is set to the object in the previous cell (0,0) instead of (0,1). Then, clicking on (0,0) will show the SelectedItem as being (0,1) and so on.

7. Repeat for any other cell.



<DockPanel Name="dockTest"

how to make webpart only show top list item?

Our office is new to SharePoint (including me!).  On our new SharePoint intranet I want to create a SharePoint Tips list.  I then want to put a WebPart on the home page that only shows the most recent tip added to the list.  I can't figure out anyway to configure that.  Thanks for suggestions.

How to make a sharepoint list column readonly or invisible while add/edit list item in sharepoint UI


 Hi Everybody,

I have created a list in sharepoint. In that list there is a field which I want to make read only or invisible when the user tries to add or edit a list item through sharepoint UI. I want this because that particular field gets populated through a webpart and direct data entry into that field is unnecessary. Is there any way to make a sharepoint column (for me its a picture column) read only or invisible in the sharepoint UI.

thank you,

Arun Dutt

How to make a ListBox focusable?


I have some F1 help stuff and need a particular listbox to be focusable, so that when the user hits F1 on the listbox, the correct help topic comes up.  Everything is fine except I can't seem to make the listbox focusable.  I tried in the XAML Focusable=true, but that doesn't seem to work.  When i use Snoop, I can click "Focusable" in snoop and then it works.  What is going on?  All of my textboxes, buttons etc work fine.  Also, on one other control the F1 doesn't work if I have a PreviewKeyDown event.  When i get rid of that, it works also?

<StackPanel Grid.Column="1">
<StackPanel Orientation="Vertical">
<Label Content="Regions" Style="{StaticResource SubLabel}"
Width="75" HorizontalContentAlignment="Left" Margin="0,0,350,0"/>
<ListBox Name="RegionsLB" Height="150" Width="425" ItemsSource="{Binding Path=Regions}"
help:Help.Topic="Primary_Panel\Primary Region Display.htm" Focusable="True" >

trouble displaying data from selected item in listbox


I have a asp.net web form in which I display registered customers in a listbox. In the listbox I can choose one customer, and click a "Show data"-button. That should display all registered data about the chosen customer in textboxes next to the listbox. This doesn't work and I haven't been able to find where the error lies. Instead of displaiyng the data in the textboxes the error message in:  LabelNoCustomerChosen is displayed. Could it be that the program doesn't find the customer ID? The string that is displayed in the listbox looks like this:

ID Lastname, Firstname

Here's my "Show data"-button click:

protected void ButtonCustData_Click(object sender, EventArgs e)

        string Firstname;
        string Lastname;
        string Street;
        string No;
        int Zip;
        string City;
        string Email;
        string Phone;

        if (ListBoxSearchCust.SelectedItem == null)
            LabelNoCustomerChosen.Visible = tru

Extending a ListBox Control - How to make the extended type require the listbox items implement a ch


I am working on a drag and droppable timeline control, and I am making decent progress.  What I have so far will work decently enough with MVVM design patterns, but I am inexperienced with this kind of advanced control extending so I am sure that some of my methods are crude at best.

I have an extended content presenter control that I want to ensure is what is actually used inside my specialized listbox.  Right now I do the following:

<DataTemplate x:Key="TempTemplate" DataType="{x:Type local:TempDataType}">

			<tt:TimeLineItemControl StartTime="{Binding Path=StartTime}

click event on ListBox item


        <Style TargetType="ListBox" x:Key="ImagesBasket" >
            <Setter Property="ItemTemplate">
                            <Border  BorderBrush="Black" BorderThickness="1" CornerRadius="5" Margin="6" Name="border">
                                <Image Source="{Binding URL}"  Stretch="Fill" Width="100" Height="100" >

How to make a TreeView's and ListBox's SelectedItem stay in sync? (in an MVVM app)



I'm certain this has come up before, but I haven't been able to find the answer.

I made a basic ViewModel that contains a list of People (an array of Person) with a property called SelectedPerson, which naturally points to the currently selected Person in the list of People. I also have a ListBox and a TreeView that are databound to the ViewModel's People list.

What I'd like to do is to keep the ListBox's SelectedValue and TreeView's SelectedItem in sync with with the ViewModel's SelectedPerson. The idea is that no matter how the SelectedPerson is modified (through a control, through code, etc), all the controls should update themselves properly by selecting the correct item. I can get it to work with two ListBoxes, which is nice, but I can't get it to work with a ListBox and a TreeView because the TreeView's SelectedItem is readonly and apparently unavailable through XAML.

Where should I look to get ideas on making this work?

Also note that I'm trying to make this work in pure XAML. No code-behind as XAML files in my application can be loaded and changed dynamically.


How to make a DropDown ListBox non-centered?


Hello, I put a DropDown ListBox on a Form.  It is centered in a td.style control.  Basically, I am trying to figure out how to make it non-centered.  I'd like to place it in a specific spot and have it stay there, but I can't seem to un-center it.  I've done this before, a while back.  Now, I forget how to do it.  Below is my code:

<td>&nbsp;<b><span><a href="Login.aspx"
        <span><asp:DropDownList ID="DropDownList1" runat="server"
            AutoPostBack="True" Width="162px">
        <br />
        <br />
            <span> <a href="Login.aspx"
        <asp:DropDownList ID="DropDownList2" runat="server">

How to make borders of a report item as rounded corners in rdlc?


Am designing a report using rdlc with report items such as rectangles and lists. I want to make those borders as rounded/blunted corners.....

Is there any possibilities to make it possible?



Thanks in advance.

I need an advice on how to make "Watch This Item" on my page


Hi everybody,


I am facing a decision now on how to make a "watch this item" function, like the one on ebay!

I was thinking to make a SQL datatable with two fileds, for example: UserID and ItemID, and to store data there,

but I am afraid if I do it like this, my server performance will slow down. For example if I have about 10.000 users

and everyone is watching just about 5 items, then my datatable will have about 50.000 entries. I am not really familiar with

server performans when dealing with such big datatables. What do you think? Am I going to face problems with server performance

if I do it this way?


Second method that I was thinking is to automatically create a datatable for every user in which ItemID will be stored

later. With this method I will not have a huge datatable, but then I will have about 10.000 small datatables.  Is this a better method?


I will really apreciate any advice or sugestion on how to build this function!


Thank You in advance!


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend