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

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

Databinding a Listbox from XAML not working

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :JQuery


I'm trying to bind a Listbox to data.  I am able to do it in the code-behind.  However, I would rather do it in the XAML,  but I can't seem to get it working.

In my code-behind it looks like this:

 Binding myNewBindDef = new Binding("SettingItems");
 myNewBindDef.Mode = BindingMode.OneWay;
 myNewBindDef.Source = manager;
 BindingOperations.SetBinding(AvailableSettings, ListBox.ItemsSourceProperty, myNewBindDef);

That works fine....the manager object has a "SettingItems" property  which is an observable collection.

When I try to do the same in the XAML

<ListBox Name="AvailableSettings" Width="150" ItemsSource="{Binding Source=Manager, Path=SettingItems, Mode=OneWay}" ...etc>

This doesn't work...Any ideas of what I am doing wrong?


View Complete Post

More Related Resource Links

Working with DropDownList and ListBox Controls in ASP.NET

"In my application i am using dropdownlist to display all categories from a table. When the user clicks this control I display all records in that category. Category table also contains column called color.

I wanted display some categories in dropdown list different color and others in different color using ASP.NET."-Anonymous

VS2010 XAML namespace intellisense not working

When I type in a namespace in XAML, I'm not getting any intellisense. For example: xmlns:local="" In VS2008 I would get a long intellisense list here. In VS2010 I get nothing. I have tried this on 2 different computers. What am I missing?

XML databinding - accessing attributes of ParentNode from childNode in XAML

Hi All, I would like to get the ParentNode of a given childNode for the xml databinding in XAML. So what should I do ??? For instance: [XML] <Answer           Margin="40,1,1,1"           TabIndex="4"           Name="Answer"           DataType="bool"           Value="N">           <Option             Name="Y"             DisplayText="Yes"             MaxLength="1"             Width="20" />           <Option             Name="N"             DisplayText="No"             MaxLength="1"             Width="

Multiple Listbox Selection not working :(

I'm loading a ListBox this way, which works and shows the selected items: lstCollectionsType.SelectedValuePath = "ClientCollectionTypeID"; lstCollectionsType.DisplayMemberPath = "ClientCollectionType1"; lstCollectionsType.ItemsSource = MyClient.ClientCollectionTypes; foreach (ClientCollectionType item in MyClient.ClientCollectionTypes) { if ((bool)item.Selected) lstCollectionsType.SelectedItems.Add(item); } And when trying to save the data, I do it as shown below. But it's not getting the current selected data. It's showing the data of how it was loaded. Make sense? It's not changing what is selected. foreach (ClientCollectionType i in lstCollectionsType.Items) { if (i != null) { ClientCollectionType boo = MyClient.ClientCollectionTypes.SingleOrDefault(c => c.ClientCollectionTypeID == i.ClientCollectionTypeID); if ((bool)i.Selected) boo.Selected = true; else boo.Selected = false; } } Please help! Thank you so much for your time!

XAML Intellisense not working


Hello everyone, I am using VSTS2008 SP1, and after resetting my user profile settings of VSTS, Intellisense on my XAML page stopped working. And I'm not sure if this issue is related, I am also getting this error message every time I try to paste something onto the XAML page.

"Value cannot be null. Parameter name: name" with no additional details available provided

XAML intellisense stopped working for project

We are working on a WPF-based application and have recently lost XAML intellisense on the project. Here's what we've discovered:

  1. XAML intellisense only fails to work in XAML files where we reference a CLR namespace inside the current assembly (using xmlns:s="clr-namespace=Namespace.Name"). 
  2. If we clean the solution, XAML intellisense works for all XAML files no matter what namespace is referenced - even for custom controls
  3. If we then rebuild the solution, intellisense stops working again 
  4. If after building we add an assembly reference pointing to the current assembly to the namespace references (using xmlns:s="clr-namespace=Namespace.Name;assembly=CurrentAssemblyName"), intellisense works again, but building fails (I'm assuming because we're trying to reference an assembly that hasn't been built yet)

Has anyone experienced anything like this before?

XAML intellisence not working for one VS2010 project in Solution


I've got a WPF solution with 5 projects in it. For some reason...the XAML intellisense quit working and it's driving me nuts. All other intellisense is working just fine (C# for code behinds). I am "not" using any network shares as I saw on other forum posts that this might be the problem. Again...this solution was working fine before. Problem exists where ever I take it XP, W7....Please help!!!


Paul Reed

Databinding: Is code behind considered Imperative and is XAML considered Declaritive?

I'm just learning WPF and I wanted to know if databinding via code behind (create binding object, set properties, etc) is considered imperative programming and if the use of XAML extensions is considered declaritive programming.   I know the question is a bit odd, after all, who cares what it's called.  I'm just curious - I need to learn the lingo.  :D

Working with SharePoint document libraries

Document libraries are collections of files that you can share with team members on a Web based on Microsoft Windows SharePoint Services. For example, you can create a library of common documents for a project, and team members can use their Web browsers to find the files, read them, and make comments. Users with Microsoft Office 2003 can check out and edit the files as if they resided on a local or network drive.

By default, your team Web site comes with a built-in document library named Shared Documents, which is listed on the Quick Launch bar as well as on the Documents and Lists page.

ListBox tricky to set in a DataGrid/GridView

Listboxes are very tricky to set selected items in grid - there is no real nice way to do it. It would have been great if Microsoft included a property that accepts an array or comma separated values - or anything! But they only allow each item in the list to be selected individually. The way to do this in a grid is a bit messy, but it is fairly simple to implement. When a row is created (as per the event), select the items of the listbox as per the datagrid source data:

What's new in XAML of .NET 4.0

With .NET 4.0 Microsoft will bring up a improved version of XAML. This arcitle shows you the language enhancements they made.
Easy Object References with {x:Reference}

Built-in Types

Generics in XAML with x:TypeArguments

Support for Arbitrary Dictionary Keys

Use of Non-Default Constructors with x:Arguments

Use of Static Factory Methods with x:FactoryMethod

Server side validation of Fileupload control not working



I've tried this method in my code behind to try and validate that the Fileupload control has a file or not. I get the error message the the event "Server Validate" cannot be found. Can anyone tell why? Thanks.

Public Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate

' Get file name

        Dim uploadAvatar As FileUpload = DirectCast(AdvertisementForm.FindControl("uploadAvatar"), FileUpload)

        Dim UploadFileName As String = uploadAvatar.PostedFile.FileName

        If UploadFileName = "" Then
            ' There is no file selected
            args.IsValid = False
            Dim Extension As String = UploadFileName.Substring(UploadFileName.L

Row command working on all rows not selected one?



I have this code that hides a column in a gridview.  (The column houses another nested gridview).

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        If e.CommandName = "Select" Then
            If GridView1.Columns(0).Visible = False Then
                GridView1.Columns(0).Visible = True
                GridView1.Columns(0).Visible = False
            End If
        End If
    End Sub

The trouble is that if I click the select link on one row that action to hide is carried out on all rows.  How can I set this up so that it only hides the row that is selected?


upload file not working



iam using masterpage and ajax update panel, i have child page called  fileupload.aspx,i try to upload the file

but its not working , can i use updatepanel in child page , pls very urgent

looking forward for answer.

JQuery Treeview plugin is not working with Ajax page load in ie8


Hi there,

I developed a page where i m using jquery treeview plugin to generate tree. It worked fine on FF, IE8 with out ajax.

But when my page loads thro' ajax call in IE8, it is not collapsing or expanding tree.

Any idea?

Thanks in advance.

jquery confirm windows isn't working


Hi, i am using jquery to implement a modal confirm windows but it not working

i have a template field button with ajax confirm using jquery but i have a problem. Apper the confirm windows but when i click on "yes" doesn't execute the delete command. without ajax (using template field button and simple confirm windows javascript) works so well.

Can you give me a hand with this?

thx in advance!

<link href="_assets/css/StyleSheet.css" rel="stylesheet" type="text/css" />
<link href="_assets/css/confirm.css" rel="stylesheet" type="text/css" />
<script src="_assets/js/jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="_assets/js/jquery.simplemodal-1.1.1.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function() {
       $(".deleteCustomer").click(function(ev) {
                var msg = $(this).attr("title");
                confirm(msg + "?");

Keyboard shortcuts stops working in WebMatrix


I'm often experiencing that keyboard shortcuts stops working in WebMatrix. This is very annoying as CTRL-S, CTRL-C, CTRL-V, etc. stops working, all of which are heavily used when programming. It's obviously hard to explain how to reproduce this, but I was wondering if someone knows a quick-fix?

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