databinding

View visibility is not changing

I have a Shell holding 2 Views. They both use the same viewmodel, in fact the shell uses the same viewmodel as well. I have 2 buttons in the shell that are supposed to change the visibility of the the 2 views. It appears that even though the command is firing, that the value is being changed and that i have onpropertychanged configured c...

Does validation still need the binding?

In Net 3.5 to set a validation rule in WPF you had to set binding as well. Is it still true for Net 4.0? If yes, is there any easy workaround for that? I.e. setting validation without setting binding. I am asking because adding regular binded value is an overkill for me (in this particular case) -- I just show a dialog, if user clicked...

How to properly bind to a child object?

I have an object Proposal which has a property called CurrentAgency of Agency which in turn has AgencyID, Name, etc...something like this: Proposal CurrentAgency AgencyID Name Address etc... In my UI, I have a combobox that lists all available Agencies. I have bound it like this: private BindingSou...

DataGridView binding problem: "Index -1 does not have a value."

I have a datagridview bound to a binding source and a couple buttons on a form. One button adds an item to the binding source, the other removes the currently selected item. There's also an event handler that listens to the CurrentChanged event and updates the Enabled status of the Remove button. Everything is hunky dory until I go to ...

Binding DataGridView to implementing class in .NET

How should I bind my collection of T objects which implements an interface and adds more properties to a DataGrid? Here is an example: // interface public interface IPerson{ [DisplayName(@"FullName")] string Name{ get; } } // implementation public class Employee : IPerson{ [DisplayName(@"Net Salary")] public int Salary { get { ret...

Binding to property in nested objects in code behind.

The nested ViewModel is set to the MainWindow DataContext: var mainWindow = new MainWindow(); mainWindow.Show(); mainWindow.DataContext = new { MyProperty = new { MySubProperty = "Hello" } } It is easy to bind to MySubProperty in XAML: <Button Content="{Binding MyProperty.MySubProperty}"/> How can I do this bind...

WPF distinguish between coding-SelectionChanged and the mouse-SelectionChanged.

Hi everyone! I have a machiavellian question (for me). In my WPF application I have a ListBox that has in the ItemTemplate a Combobox. When the user select a ComboBoxItem, I have to do some complex operations on the ObservableCollection that is the ItemsSource of the ListBox, then I have to show the ListBox with the changed data. The pro...

asp.net DataBinding - Method - From Code Behind

hi my dear friends : the below ASPX code is ok : <asp:Label ID="lblShowInRPV1" runat="server" Text="<%# Method() %>"></asp:Label> is it possible to pass some parameters (from aspx code) to Method()? in the other hand can u fix Below databinding for me ? (That Is Incorrect) <asp:Label ID="lblShowInRPV1" runat="server" ...

How to set/bind ScrollBar.Maximum the right way in XAML?

I have written a custom control MyControl with virtual content that is much wider than the control itself, and I want to make use of the ScrollBar-control to scroll the virtual content of my own control. My control has 3 properties, that are important in this scenario: Width: the physical width of the control VirtualWidth: the width of...

Databinding repeater makes the Repeater load all items twice

I have a repeater on which I bind a list with 3 items. The databind() is called once, I have checked this using the debugger. I have some strange behavior here because the Repeater seems to walk through this list of items twice. Instead of the 3 items, I see the repeater bind everything twice. /// <summary> /// Handles the Load ...

Databinding to a custom control

Hey all, I have following situation in a C# Windows Forms (.NET 4.0) application: I have a bindingsource which datasource is set to a collection of objects of a custom class. Most properties of this class can be represented by a textbox or checkbox, as they are strings or numbers or bools. However, there is one property, called Rating...

Binding to a textbox

Hi all, I'm using a DetailsView Control to perform an insert into my database. I've no problems doing this when I set the fields for the DetailsView control on the aspx page.... <asp:TextBox ID="InsertFirstName" runat="server" Text='<%# Bind("First_Name") %>'></asp:TextBox> ...but I need to be able to do this dynamically in the code ...

Bind Data to Repeater using Ajax

Hi, I want to Bind data to a Repeater on click of a particular Button. I can do an ajax request via jQuery and call the method to bind the data, but on the page nothing is displayed. This is the method I use to bind the data to the Repeater: public void BindJobs() { if (RptClientDetails.Items.Count != 0) return; RptClientDeta...

How to bind one control to another?

I have a checkbox with a Checked property and a Listbox with an Enabled property. I'd like to data bind the controls in such a manner that when the user checks the Checkbox, the listbox becomes enabled. Conversely, when the user unchecks the checkbox, the listbox becomes disabled. How can I do something like that? ...

How to bind and retrieve information in a dictionnary<Tkey, TValue> to a ComboBox?

Hello all, I am able to bind a "MyDictionary.Value" to a ComboBox and see the Values in it: Dictionary<string, Friends> friend_list = new Dictionary<string, Friends>(); Friend_chat_list.ItemsSource = friend_list.Values; And here is the XAML code: <ComboBox x:Name="Friend_chat_list" Width="90" ItemsSource="{Binding}" SelectionChanged...

Force binding update in XAML

I have a View with a Listbox and several textboxes bound to properties of the objects displayed in the listbox. On opening, the listbox is populated with data, and I have the following in the style to ensure than when there are items and nothing is selected, to select the 1st item. <Style.Triggers> <MultiTrigger> ...

Data Binding to an XML file

I have an XML file structured as follows: <Levels> <Level Code="T" Text="Test"> <SubLevels> <SubLevel Type="9" Text="Nine"/> <SubLevel Type="8" Text="Eight"/> <SubLevel Type="7" Text="Seven"/> <SubLevel Type="6" Text="Six"/> </SubLevels> </Level> <Level Code="T2" Text="Test 2"> <SubLevels> ...

WPF DataBinding: Grid ColumnDefinition Width to UserControl DependencyProperty

I'm not sure what I'm doing wrong, but I am attempting to align my user control with the ColumnWidth of my grid using DataBinding and DependencyProperties. I have a GridView on my Form Page which contains a two instances of a user control (Address). The address usercontrol contains a textlabel "header" so that I can name the user contro...

Two-way databinding to POCO without INotifyPropertyChanged

How does two-way databinding work in Silverlight when the data source object's properties don't raise PropertyChanged events in their setters? For example, in code samples, I've seen databinding to instances of the System.Windows.Point struct, which does not implement INotifyPropertyChanged and is mutable. What happens (or should happen...

Do WPF controls use weak events in their bindings?

When I use databinding in WPF, my target controls are listening for events on the binding source. For example, I may have a ListView listening for CollectionChanged events on a ObservableCollection. If the lifetime of an event source is expected to exceed the lifetime of an event listener, there is a potential memory leak, and the weak ...