databinding

WPF - help converting XAML binding expression to codebehind

Can anyone tell me what is the c# equivalent of the following snippet of XAML ?? <my:DataGridTextColumn Visibility="{Binding Path=DataColumns[21].IsVisible, Source={StaticResource viewmodel}, Converter={StaticResource vc}}" Binding="{Binding SdDevDuration}" /> Its th...

Remember selected row in DataGridView

I'm trying to get my datagridview control to remember the selected row after data refresh. The DGV is databound to a list of business objects: Dim FXs As SortableBindingList(Of FX) = FX.LoadAllForBinding(FXStatus) Dim bs As New BindingSource bs.DataSource = FXs The overall sequence is something like this: User clicks on a row Row i...

How to add a Command to the items in a databound TreeView

How can I add WPF DelegateCommands to the items in a TreeView bound to an XmlDataProvider? I'm using the MVVM pattern and Composite WPF and I want the command to be called when the user double-clicks on an item in the TreeView. I have a TreeView defined in XAML whose DataContext is set to the XmlDataProvider: <TreeView xmlns="htt...

wpf - display, update, insert modes

Hi, Is there a simple way in WPF to create a usercontrol with different modes for display, update or insert a new object? I'm thinking (coming from a web background) something like a listview control where you can create display templates for the different modes. You can then quickly change the mode, depending what you need to do. An...

.NET DataSet.HasChanges is incorrectly false

Hi guys, Has anybody come across ds.hasChanges() being false despite that the ds clearly has the changes while you check it at a breakpoint? I've been looking at it for quite a while and I can't see what is wrong... // connectionstring and command has been set DataSet ds = new DataSet(); BindingSource myBindingSource = new BindingSourc...

Why BindingSource component cannot see inherited properties?

I have defined classes: public class Parent : IParent { public string ParentText { get { return "ParentText"; } } } public interface IParent { string ParentText { get;} } public class Child : Parent, IChild { public string ChildText { get { return "ChildText"; } } } public interface IChild ...

Animate WPF Text when binding updates, how?

Hello all! I want to be able to create a fade animation on a text element when the binding to that element updates. In other words, the effect is that as text gets added to a text box one sees a fading effect as the text updates and then fades out. I do'nt know how to achieve this. I have seen something similar using an EventTrigger on ...

A Window Binding to Self?

I'm trying to get a Window's datacontext to be set to itself, but I can't figure out what the syntax should be. <Window x:Class=" ... DataContext="{Binding Self}" Doesn't seem to work. Any ideas? Thanks! ...

How to rebind datagridview when user moves from one cell to another?

I have a datagridview where the first cell is used to retrieve data for the grid. If I use the cellleave event to rebind the grid to a datatable, I get a "Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.", which makes sense. Where can I bind the grid to a datasource after all the e...

WPF MultiBinding

I have two text boxes, one for a billing address field and one for a shipping address field. When the user types something into the the billing address text box the shipping address text box gets the same value due to the following binding scenario: <TextBox Name="txtBillingAddress" Text="{Binding BillingAddress, UpdateSourceTrigger=Pro...

Binding to an specific property of objects in an array

I am using Flex to create a small form. All I have at the moment is a List component, that I want to populate with a list of font names. I am getting the fonts using Font.enumerateFonts(true);. This returns an array of flash.text.Font objects. The Font objects have a fontName property that is a String of that fonts name. My problem is...

WPF Data Binding - Displaying the list of system fonts

Using XAML, I am trying to get a list box to display the list of system fonts. I am not sure exactly what to type in the Bindings string. Here's my attempt: <Window x:Class="ListDataBinding.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmln...

Bind WPF ComboBox SelectedValue-property to multiple objects

Let's say I have a list of Customers (List) and each Customer has a State-property. Is it possible to bind the SelectedValue of a ComboBox, so that it shows (has a SelectedValue of) e.g. "WA" if all Customers have WA as their State? If the customers have different State-values nothing is shown. But if I then choose OR, then all Custome...

ASP.Net databinding for lists versus value types

I have a question about ASP.Net data binding - for a small internal tool I'm creating. Simplifying the scenario, there's a page with some Repeater controls to display lists/tables, and also some edit boxes. Within Page_Load() I bind all the Repeaters from a business object (stored in ApplicationState). If it's not a postback then I also...

ListBox DataTemplate Binding With Two Lists

Hi, I'm databinding a listbox to an object that contains two array of strings. Each listbox item is set to a data template made up of a textbox and a combo box. The first string array is bound to the list, and the second string array is bound to the combo box. Well, at least that's I'm trying to achieve. The problem is that I can't figu...

Updating bound controls to ApplicationSettings

I'm attempting to utilize the .NET 2.0 ApplicationSettings feature for the first time, and find it a bit... puzzling in some ways. I'm hoping someone can help me figure out where i'm going wrong. I have a generic settings class which i've implemented that is a subclass of ApplicationSettingsBase. I've implemented a property, and tagge...

Problems with data binding in ItemContainerStyle in Silverlight 3

I'm unable to use data binding in the ItemContainerStyle for a ListBox in Silverlight 3. It works fine in WPF. This is contrived example to demonstrate my problem. What I really want to is bind to the IsSelected property, but I think that this example is easier to follow. I have a ListBox that is bound to a ObservableCollection<Item> of...

How do I make sure my WPF TabControl always has a selected tab when it contains at least one tab?

I have a TabControl whose items are bound to an ObservableCollection: <TabControl ItemsSource="{Binding MyObservableCollection}" /> The tabs are added and removed as expected as items are added and removed from the collection. However, the SelectedItem reverts to -1 (meaning there is no selected tab) whenever the collection is empty. ...

howto avoid massive notification in DataBinding

Hi, I guess it's quite a common problem in databinding scenarios. What do you usually do, if you are running a batch update and want to avoid that a propertychanged-dependend calculations/actions/whatever are executed for every single update? The first thing which usually comes to my mind, is to either introduces a new boolean or unhoo...

combobox in C# not getting populated

Hi, I have a windows forms app in C#. Platform is vS 2005. Following is the piece of code: namespace HostApp { public partial class Form1 : Form { private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { comboBox2.Items.Add("Apples"); comboBox2.Items.Add("Ora...