databinding

Correct way to unbind a BindingSource from a DataGridView

I have a BindingList<> of objects, set to the DataSource of a BindingSource. This is set to the DataSource of a DataGridView. I'm concerned with not causing any potential memory leaks, so wondering if there is a preferred way to unbind these connections when I am finished with the data. I'm thinking of: datagridview.DataSource = null;...

WPF: How can I wrap the items in a ItemsControl in another Template?

I have an ItemsControl that contains items that each has its own DataTemplate. Each ViewModel class in the ItemsSource derives from a common ancestor that has a Header property. I want to wrap each item in a Expander control, but my problem is that I don't know how to 'carry over' each 'DataTemplate' to the DataContext of the expading p...

How to resolve bound object from bindingexpression with WPF?

Hi does anyone know if there are any inbuilt classes for resolving a bound object from a bindingexpression and it's DataItem and property path? I'm attempting to write a Blend 3 behavior for textboxes which automatically invokes methods on an object bound to the textbox Text property. The textbox is bound to a property on a viewmodel c...

Compilation of <%# %> expressions

Is there a way to force VS2008 to compile <%# %> databinding expressions to avoid runtime errors? ...

Is it possible to use Data-Binding Expressions directly in markup to show/hide content?

I would like to do something like: <%# if((bool)Eval("IsDisabled")){ %><span>Disabled</span><% } else { %><span>Active</span><% } %> but I don't think its possible. There is a way to create method in codebehind which returns appropriate string and call it, but thats not an option. ...

[WPF] Creating a GridView from a table structure

Is there a library/CLR command that allows me quickly (in a few lines of code) convert a tabular data structure (say List<List<string>>) into a displayable WPF DataGrid? I'm looking for a function like: ListView FromIEnumerable(IEnumerable<IEnumerable<object>> source) {...} Which would be used as panel.Content = FromIEnumerable(Read...

c#.net ListView - pull different information back from different tables

Hello all, I’m using c#.net. I have been looking round the web and can’t find anything that helps me out. I have a list of contractors, daily hours, daily slots (three different tables). First row - contains the contractors names. Second row - unlimited - contains the slots. For example I thought I could use a ListView howeve...

WPF -- List / Detail Different Windows can they be synchronized and databound to the same collection?

I have a listbox that is bound to a List<T> -- this is working great. I'd like to let my users double click a listbox item and open a new window that will display the "detail" view for that record. I'd like this new window to be databound to the same collection as the listbox on the original window. Because, that window has a timer, wh...

How can I bind a button control to a cfc to toggle a boolean database value

I would like to able to bind a series of 3 buttons to toggle 3 boolean values on a database message entry. The boolean database entries are read|unread, actioned|pending, referral|message and the message entry has the unique key "messageID". I want the buttons to display the record starting values (which I presume is bindonload="true"). ...

Binding a custom object to a canvas in wpf

I am creating a report designer and so i have a need to add/remove fields and move them around in the designer. I have a custom canvas (extending the Canvas class) with a matrix of labels that I am able to drag around. I would like to build up all these labels dynamically from a databound data source. What would be the best way to do th...

ASP.NET Binding integer to CheckBox's Checked field

I have a following ListView item template, in which I am trying to bind integer value to Checked property of CheckBox. IsUploaded value contains only 0 and 1... <asp:ListView ID="trustListView" runat="server"> <ItemTemplate> <asp:CheckBox ID="isUploadedCheckBox" runat="server" Checked='<%# Bind("IsUploaded") %>'...

Flex: Binding to an MXML-esque "binding string" in action script?

Is it possible to specify MXML-esque "binding strings" in ActionScript? For example, I want to be able to do something like: MXMLBinding(this, "first_item", this, "{myArrayCollection.getItemAt(0)"); MXMLBinding(this, ["nameLbl", "text"], this, "Name: {somePerson.first} {somePerson.last}"); Edit: thanks for the...

Do data source binding in Global.asax??

Hi~guys... I knew global.asax normally is used for session stuffs, or error handling. However, I saw someone's code, and he did data source binding in global.asax. Moreover, it's like every source he might used in there...Whould this cause any serious problem? or it's just ok...? and, any advantage of it? By the way...Sorry i forgot whe...

How do i get the control that is bound to a property in the ViewModel's end?

In WPF, how do I get the control (FrameworkElement) that is bound to a property in a viewmodel's end? I want to create a drop shodow effect on the control. ...

Silverlight 3 - binding enum to combobox from DomainServiceContext

Hi, I just started playing around with Silverlight and a supposedly simple thing like binding a Combobox is driving me nuts. I read a bunch of articles now but none really address the issue that I'm after or were made for Silverlight 2 and don't seem to work. Let's say I have an entity object "User" which has a "UserStatus" field. In t...

Display lookup value based on foreign-key in bindingsource

Hi All, I am looking for "best-practices" to display the value of foreign-key in a BindingSource. Sample data: PetID---PetName---PetTypeID 1---Tom---1 2---Jerry---2 PetTypeID---PetType 1---Cat 2---Mouse I have a Pet class and Pet form. The following code is on the Pet form to return data from the database as a Pet collection and ...

sliverlight and binding to anonymous types

ScottGu indicated in an admittedly old post that databinding to anonymous types "just works" because anonymous types are just "syntactic sugar" (whatever that means) and from the CLR perspective they are every bit as real a type as anything I would write up. However Mike Hillberg posts that such is not the case with silverlight, and i...

Binding WPF ComboBox to entity.

Ok, Ive searched the heck out of the Interwebs and can't seem to find this right. I have a ComboBox that is bound to a CollectionViewSource of EntityFramework entities. The display is a template that shows the first/last name. The problem is, when an item is selected, the Display of the combobox == the object.ToString() (i.e. MyCompan...

How come the getter on a property on an object fires even though no part of my form is asking for that property?

Normally a databound winform only fires the getters for the properties which match textboxes, grids etc But as I page through a collection (via BindingNavigator NextItem/PreviousItem), I'm finding that if I set a datagrid's DataSource to a property, then remove it, that property getter thereafter continues to fire even though the grid o...

Silverlight Update/Trigger IValueConverter in Listbox DataTemplate in a DataGrid

Hi I am building an application to display a datagrid bound to an ObservableCollection of Records, where each record has a Course Object and an ObservableCollection of Results Objects. The course is changed using an autocomplete box. The results collection is displayed in a Listbox with an IValueConverter implementation to change the c...