databinding

Silverlight XAML Binding -- Decimal to Double

I've got some Columns in a DataGridView that have their Binding property set to something like the following: Binding="{Binding NetPrice}" The problem is that this NetPrice field is a Decimal type and I would like to convert it to Double inside the DataGrid. Is there some way to do this? ...

DataBinding with a DataRow - problems

Hello, I am currently coding a project under c# and am experiencing problems. I'll give a brief description of my form: It has a datagridview on the bottom half of the form with single row selection, and is read only. On the top half of the form I have various components which are databound to the selected row on the datagridview. I di...

Adding new row datagridview to use default values

Hi, I have the following SQL that creates a table and inserts the first row of data without a problem. The default DateTime values are also inserted as expected. CREATE TABLE Jobs ( [Id] int PRIMARY KEY IDENTITY(1,1), [JobName] nvarchar(256) Default 'SomeName', [CreateDate] DateTime DEFAULT GETDATE(), [ModifyDate] ...

C#: Binding hashtable to combo box question

public class FontType { ... public String Name { get { return _name; } } public String DisplayName { get { return _displayName; } } public Font UseFont { get { return _font; } } } bindFontTypes.DataSource = availableFonts; comboFontType.DataSource = bindFontTypes; comboFontType.ValueMember = ...

Wpf Databinding and Converters

I'm trying to databind to a listbox like so: <ListBox x:Name="MyListBox" Margin="0,0,0,65"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Converter={StaticResource MyConverter}}" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> The reason I am binding to the whole object and not a property is beca...

When should you use Page.DataBind() versus Control.DataBind()?

In ASP.NET, you can bind controls individually (i.e. GridView1.DataBind()) or you can call Page.DataBind() to bind all controls on the page. Is there any specific difference between the two calls? Are there times when one should be preferred over the other? ...

WPF Paged CollectionViewSource

I have a WPF ListBox that I would like to add pagination to as it starts getting slow with a bunch of items. My problem is that I use the Grouping, Sorting, and Filtering. That means if I were to limit the data with the LINQ Skip() and Take() methods or using something like a paginated ObservableCollection the grouping and sorting would ...

Critique my JAXB object wrapper.

Hello Ladies and Gents, I have a question on wrapping a jaxb created class and would really like to hear your inputs. My xsd looks a bit like: <ComplexService> <ComplexObject1> <Element1></Element1> <Parameter></Parameter> </ComplexObject1> <ComplexObject2> <Element2> </Element2> <Parameter> ...

TreeView bound to XMLDataProvider - shows data in editor, but empty when run

I have bound a TreeView to an XMLDataProvider. The TreeView displays the data as expected in the Visual Studio editor. But when I press F5, the application runs but the treeview is blank. Does anyone know why I can't see it when I run the application? Here's the entire code: <Window x:Class="TreeViewDataBinding.Window1" xmlns="htt...

How can I bind the nested viewmodels to properties of a control

I used Microsoft's Chart Control of the WPF toolkit to write my own chart control. I blogged about it here. My Chart control stacks the yaxes in the chart on top of each other. As you can read in the article this all works quite well. Now I want to create a viewmodel that controls the data and axes in the chart. So far I'm able to add a...

WPF Grouping using CollectionViewSource and DataBinding

I'm binding a CollectionViewSource to a ListView to group items. It all works great except when I update the ObservableCollection the CollectionViewSource is based on. If I update a value of an object in the collection the UI is never updated. Here is an example: <ListView x:Name="MyListView" Margin="0,0,0,65"> <ListView.Gro...

Applying a Style to a control that plays an animation based on a databinding to the view model and a control specific field?

So here's the situation, I have a control (code below) that plays an animation from a style datatrigger when a viewmodel property is equal to a value (Binding="{Binding OperatorState}" Value="Blah") Trouble is, although I can bind the BINDING I can't bind the value, as Value appears to have to be a literal. I wanted to do something like...

ListBox doesn't show changes to DataSource

I thought this was a simple problem, but I can't find any information on the web. I'm binding a ListBox to a List using BindingSource like so: List<Customer> customers = MyMethodReturningList(); BindingSource customersBindingSource = new BindingSource(); customersBindingSource.DataSource = customers; customersListBox.DataSource = cust...

WPF Refresh Model on binding

Hey, I was wondering if there was a way of calling a method or updating a property on my ViewModel object when WPF binds to the object ? The reason I want to do this is that when my viewModel objects get created their data model only contains an ID that is used to query data from the database when necessary. So when the user navigates t...

Does Winforms DataBinding work for programmically changed properties?

I have some UI controls that are using DataBindings.Add method, and it works if I change the specified UI property by hand, or the source object is changed outside. But if I invoke the UI.Property = value in code, then it doesn't change the UI nor the source object that's specified for DataBindings.Add. What am I doing wrong? Am I usin...

C# Binding Generic LIst<string> to Combo Box

I have a combo box and I want to bind a generic List to it. Can anyone see why the code below won't work? The binding source has data in it but it won't fill the combo box data source. FillCbxProject(DownloadData Down) { BindingSource bindingSource = new BindingSource(); bindingSource.DataSource = Down.ProjectList; cbxProjectd.D...

WPF: Scroll into view a new item in a ItemsControl

I have an ItemsControl that is databound to a ObservableCollection. I have this method in the code behind which adds a new model to the list. I would then like to scroll the new item (at the bottom of the list) into view. I think the size of the ItemsControl is not yet updated when I am querying the size, since the ActualHeight before a...

Listing all Validation.Errors in a single WPF control?

I'm trying to find a simple way of binding a single control (eg. TextBlock or ListBox) to list all the validation errors on a WPF form. Most source code examples I have been able to find just bind a control to (Validation.Errors)[0].ErrorContent which only shows a single validation error. I'm currently using ValidationRule classes, thou...

How can I use DataBound controls with a disconnected architechture in ASP.NET?

When I'm developing ASP.NET applications I often create forms that allow users to create, retrieve, or update records in a database. Many times there's a need to be able to add child records to an item I am creating, such as adding a category to a product or some sort of order / order detail relationship. Normally I use some sort of Dr...

Winforms data binding for TextBox

I have a basic property that stores an object of type Fruit: Fruit food; public Fruit Food { get {return this.food;} set { this.food= value; this.RefreshDataBindings(); } } public void RefreshDataBindings() { this.textBox.DataBindings.Clear(); this.textBox.DataBindings.Add("Text", this.Food, "Name"); }...