databinding

Best Way to DataBind a List with sub-related content (For example, SO's questions with tags)

Using ASP.net 2.0, how do I present the information to the user similar to the Questions list on SO where each question has some child items (like the tags). I would probably be making two separate queries, one to first find the list of questions, then another query to find all tags which belonged to the list of questions. Approach 1: ...

How to populate a WPF grid based on a 2-dimensional array

I have a 2-dimensional array of objects and I basically want to databind each one to a cell in a WPF grid. Currently I have this working but I am doing most of it procedurally. I create the correct number of row and column definitions, then I loop through the cells and create the controls and set up the correct bindings for each one. ...

Is there a way to bind the results of a public method in xaml.cs to a control in xaml?

Let's take a very simple example: In my window1.xaml, i have a label control named 'lblProduct'. In my window1.xaml.cs, i have a public method called CalculateProduct(Int Var1, Int Var2). CalculateProduct will, as you may have guessed, calculate the product of the variables passed in. I'd like to simply bind the results of 'Calculat...

Read-only DataGridView and IEditableObject

Good evening I've got a little problem with my DataGridView in a .NET Windows Forms project. The grid is read-only and bound to a sortable BindingList<T> which contains custom business objects. My business object class does implement IEditableObject. Now the BeginEdit and EndEdit methods are called all the time while navigating in the ...

Silverlight - Data binding not listening for PropertyChanged event

Could somebody please explain to me what happens here? I am creating a binding in code. The target object is a UserControl The target property is a boolean DependencyProperty The source object is a FrameworkElement and implements INotifyPropertyChanged The source property is of type ObservableCollection What happens: The binding ...

Changing a ListBox selection changes other ListBox's selection. What's going on?

I've got a Windows Forms application with two ListBox controls on the same form. They both have their SelectionMode set to 'MultiExtended'. When I change the selection of one the selection of the other changes. Now I thought I'd done something stupid with my SelectedIndexChanged handlers so I removed them and re-wrote them from scratc...

Constraint vs. Validation?

I am working with Windows Forms Databinding, implementing interfaces like IDataErrorInfo. In order for this to work, the domain(or business) object is allowed to be in an invalid state. In fact, the domain object needs to retain the invalid value as the user entered it for IDataErrorInfo to work properly. As long as the object isn't p...

How do I trigger a style change if DataContext is null or not using WPF

I have a page with several controls. The controls are bound to display values which they get from the page's DataContext. What I would like to do is display another look of the page should the DataContext be null. In some cases the controls of the page should display differently if "their" property is set or not. Is is possible to creat...

Using data binding to launch animations in WPF

I am trying to adapt a simple WPF application to use the Model-View-ViewModel pattern. On my page I have a couple of animations: <Page.Resources> <Storyboard x:Name="storyboardRight" x:Key="storyboardRight"> <DoubleAnimation x:Name="da3" Storyboard.TargetName="labelRight" Storyboard.TargetProperty="Opacity" From="0" To="1" D...

Add my linq query resultset to a dataset, c# asp.net 3.5

My query is: var query1 = from u in dc.Usage_Computers.AsEnumerable where u.DomainUser == s3 orderby u.OperationTime descending select new { u.ProgramVersion, u.OperationTime, u.IPaddress, u.ComputerName, ...

WPF: Problem with binding values to ComboBox inside GridViewColumn

My Views dataContext is bounded to a presentationModel with two observableCollections Members. In the View I have one listView which ItemSource is bound to is the first observableCollection. In one of the LilstViews column I want to present values from the second obeservable Colletion in my presentationModel. I cant figure out how to get...

Does it matter if I use RowDataBound or DataBound for a GridView

According to the VS 2008 properties for a GridView: DataBound fires after the control has been databound. RowDataBound fires after a row has been databound. If I want to manipulate the text in a header column, does it matter if I use the DataBound or RowDataBound because I can always just check the e.Row.RowType. Is there an actual ...

INotifyPropertyChanged vs. DependencyProperty in ViewModel

When implementing the ViewModel in a Model-View-ViewModel architecture WPF application there seem to be two major choices how to make it databindable. I have seen implementations that use DependencyProperty for properties the View is going to bind against and I have seen the ViewModel implementing INotifyPropertyChanged instead. My quest...

Silverlight DataBinding Error - Works in WPF Though!

Start a new Silverlight application... and in the code behind (in the "Loaded" event), put this code: // This will *NOT* cause an error. this.LayoutRoot.DataContext = new string[5]; But... // This *WILL* cause an error! this.LayoutRoot.DataContext = this; The error that is raised is "Value does not fall within the expected range." ...

WPF - HeaderStringFormat Doesn't work in Expander

I can't seem to find the magic combination to make the HeaderStringFormat work for a WPF Expander. Here are all the things I've tried: <Expander Header="{Binding Path=MyProperty, StringFormat=Stuff: ({0})}" > <TextBlock Text="Some Content" /> </Expander> <Expander HeaderStringFormat="{}Stuff ({0})" Header="{Binding Path=MyProperty...

WPF TwoWay Bind to current source with Converter?

Is there an issue with databinding in WPF when you bind to the current source (Path=".") and using a converter? The two way binding doesn't seem to work in this situation. I know I could change the path, but I want to be able to pass the "Name" value to the converter. I can't get the following example to work: <Window x:Class="WpfTest...

dotnet: ListChangedType.ItemDeleted is useless?

The ListChanged event for an IBindingList fires a type ListChangedType.ItemDeleted when items are deleted, perhaps by a user deleting a row in a datagrid control bound to the list. The problem is that the NewIndex into the list is invalid in this event, it's been deleted, and the item that was deleted is not available. There should be an...

asp.Net GridView bind custom object with nested List

Hi All, I have a List of custom object, which consist of a custom list. class person{ string name; int age; List<friend> allMyFriends; } class friend{ string name; string address; } I'trying to bind a list of these objects to a GridView and the Grid should create for each friend a column and write the name in it. If some p...

Problem with WPF data binding and Access Keys

Please consider the following example. Note that in the real-word, the binding source will likely be a data object. I'm using a TextBlock for simplicity. <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height=...

Using a WPF toolkit DatePicker as a parameter to an ObjectDataProvider used as an itemssource

This one has me beat; I have a WPF window with two (important for this case) controls, both from the WPF toolkit available at CodePlex; A DatePicker and a DataGrid. The DataContext of this window is set to a CLR object that has all the information it needs. This CLR object has a large list of data, and a method called GetDataForDate( D...