databinding

DependencyProperty and DataBinding?

In WPF: Can someone please explain the relationship between DependencyProperty and Databinding? I have a property in my code behind I want to be the source of my databinding. When does a DependencyProperty (or does it) come into play if I want to bind this object to textboxes on the XAML. ...

What are the limitations of Loose XAML?

I have been experimenting with WPF and rendering strict XAML markup in a web browser, also known as Loose XAML (explained here and here). It strikes me as mostly useful for displaying static content. However, it also appears possible to bind to an XML data provider. Loose XAML files are not compiled with an application, which create...

ListBox with Grid as ItemsPanelTemplate produces weird binding errors

I've got a ListBox control and I'm presenting a fixed number of ListBoxItem objects in a grid layout. So I've set my ItemsPanelTemplate to be a Grid. I'm accessing the Grid from code behind to configure the RowDefinitions and ColumnDefinitions. So far it's all working as I expect. I've got some custom IValueConverter implementations fo...

How do I pass data between activities in Windows Workflow?

I'm not completely sure I understand the workflow way of doing things, but if it's a pipeline n filter style model I should be able to pass data (even strings) from one activity to another. Does anyone know how to do this? Bonus points for a video! I hope this is possible. If WF were the same as my idea of it then it would be extremel...

WPF Bind to a Collection of objects, sorted by IDs stored in order in another Collection in C#

For those of you that like puzzles: I had this problem recently and am sure there must be a nicer solution. Consider : an ObservableCollection of Foo objects called foos. Foo contains a string ID field I have no control over foos foos will be changing Then: I have another collection called sortLikeThis sortListThis contains string...

INotifyPropertyChanging and validations: when do I raise PropertyChanging?

INotifyPropertyChanged is fairly self explanatory and I think I'm clear on when to raise that one (i.e. when I've finished updating the values). If I implement INotifyPropertyChanging I'm tending to raise the event as soon as I enter the setter or other method that changes the objects state and then continue with any guards and validatio...

How do you bind a DropDownList in a GridView in the EditItemTemplate Field?

Here's my code in a gridview that is bound at runtime: ... <asp:templatefield> <edititemtemplate> <asp:dropdownlist runat="server" id="ddgvOpp" /> </edititemtemplate> <itemtemplate> <%# Eval("opponent.name") %> </itemtemplate> </asp:templatefield> ... I want to bind the dropdownlist "ddgvOpp" but i don'...

WPF Data Binding and IValueConverter

Why is it that when I use a converter in my binding expression in WPF, the value is not updated when the data is updated. I have a simple Person data model: class Person : INotifyPropertyChanged { public string FirstName { get; set; } public string LastName { get; set; } } My binding expression looks like this: <TextBlock Text="{B...

Simulating <%#Bind(...) %>

ASP.Net: In code-behind I can simulate <%# Eval("Property")%> with a call to DataBinder.Eval(myObject,"Property"); How do I simulate a call to <%# Bind("Property")%> ? many thanks ...

Transfer Dependency Property value of a UserControl to a Control inside it

I have a UserControl (Composite control) that can be shown as the following pseudo XAML code: <UserControl> <DockPanel> <TextBox /> <Button /> </DockPanel> </UserControl> I use this custom control in a bunch of places and style some of them with a WPF Style. This style sets the Background property of the UserControl to a c...

How to validate a property of a custom object in a databinding scenario (i.e. BindingList)?

When you a set a property's value, you can either validate before or after updating the internal value. If validating before, you could throw an exception if the new value is invalid. The object is then always in a valid state. If validating after, undo is desired (i.e. via IEditableObject), so the user can cancel the edit any time. ...

How to databind a property within a property

I cureently have a set up like below Public ClassA property _classB as ClassB End Class Public ClassB property _someProperty as someProperty End Class what I want to do is to databind object A to a gridview with one of the columns being databound to ClassB._someProperty. When I try to databind it as Classb._someProperty I ge...

How does Databind consume a DataReader

If I have a control on a page that has its Datasource set to a DataReader, does that control consume the reader at the time the Datasource is set, or does the datareader continue to exist until Databind has been executed? What actually happens under the covers when Databind is executed? ...

What other objects are accessible inside <%# %> tags in aspx?

I run into similar codes like this all the time in aspx pages: <asp:CheckBox Runat="server" ID="myid" Checked='<%# DataBinder.Eval(Container.DataItem, "column").Equals(1) %>'> I was wondering what other objects I have access to inside of that <%# %> tag. How come DataBinder.Eval() and Container.DataItem are not visible anywhere inside...

How do I tell if a class property has a public set (.NET)?

I have this: public string Log { get { return log; } protected set { if (log != value) { MarkModified(PropertyNames.Log, log); log = value; } } } And my utility class for databinding ...

Two-way binding of Xml data to the WPF TreeView

I am attempting to rewrite my ForestPad application utilizing WPF for the presentation layer. In WinForms, I am populating each node programmatically but I would like to take advantage of the databinding capabilities of WPF, if possible. In general, what is the best way to two-way databind the WPF TreeView to an Xml document? A generi...

XML Data Binding with Namespaces

I want to use data binding with an XML document to populate a simple form that shows details about a list of people. I've got it all set up and working like so right now: <Window x:Class="DataBindingSample.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Ti...

Getting the Bound Field Name at Run Time in ASP.Net

If I have a control, within a FormView, that is bound using a <% #Bind(...)%> expression. At run time, is there any way of retrieving the name of the field the control is bound to. To be clear, if the expression is <% #Bind("UserName") %> I want to return the string "UserName". ...

How to set selected row of DataGridView to newly-added row when the grid is bound to sorted DataView?

I have a DataGridView bound to a DataView. The grid can be sorted by the user on any column. I add a row to the grid by calling NewRow on the DataView's underlying DataTable, then adding it to the DataTable's Rows collection. How can I select the newly-added row in the grid? I tried doing it by creating a BindingManagerBase object boun...

DataTable + DataGrid Data Binding Performance Againsts Custom Data Source Object + Data Grid

In our industrial automation application, we need to capture and display the data in the milliseconds. We have data binding between data grid control and a DataTable object. We have around three hundred records which needs to be display in the grid. So we update the 300 records every time we get the records. Example TabularVi...