databinding

Why is Container.DataItem being passed as a string literal?

I'm trying to pass a string value to a javascript function from a LinkButton's OnClientClick event, but the function is receiving "<%# Container.DataItem %>" instead of the value. Here's the code: OnClientClick="javascript:SaveQuotaGroupCode('<%# Container.DataItem %>');" The container is a collection of strings. Why is it not evalu...

WPF Datagrid Dropdown binding to other items in the same datagrid

Morning folks, I think I've got my head around basic databinding in WPF, but I'm not sure how to go about this problem. I have a datagrid that the user adds items to, and I'm trying to make one column a 'depends on' column, so that when the column is in edit mode it contains a dropdown box of all the names of the items in the datagrid e...

How to get two different textboxes bound to two different data context?

Hi everyone, Normally we bind a textbox's Text property to a data-context's properties. The data-context can be 1) the code behind (default) and 2) the view-model, 3) others which specified in Initial method of the form (this.DataContext = ... ). What I want to do: bind two textboxes to two different data context in the same form. How c...

NHibernate list/detail views using different sessions, but changing same object

Hello, My application consists of two views, list and detail. Basically when user double-clicks a row from a list, I pass selected item object to detail view. Every instance of view has it's own NHibernate session. When user modifies object properties, my list view needs to reflect changes, to do this I implemented INotifyPropertyCha...

named binding of variables in strings?

I'm looking for function like sprintf(), except whereas with sprintf() you bind the values by order of arguments, I want something where I can bind variables by name. So, if I had the string "Hello $name! We're please to have you visit, $name!", you could pass an array or something and get the resultant string from it. Something like th...

Winforms binding data

If I have a grid with a list of items (IList<x>) and a textbox on the form, is there a way to bind the data so that as I click a row that the textbox.text gets updated, without doing it explicitly? In other words, I want to be able to use Binding() or some other way, and not do OnSelectionChanged textbox.text = x.somefield as I will...

How to programmatically set SelectedItem of a data-bound WPF ComboBox?

Question: Can anyone please provide a full code example that shows how one does programmatically change the SelectedItem of a data-bound WPF ComboBox without using MyComboBox.SelectedIndex? Code sample: Here is what I currently have. XAML: <Window x:Class="Wpf.ComboBoxDemo.MainWindow" xmlns="http://schemas.microsoft.com/winfx/...

WPF DataGrid Binding DataGridCell Content

Hi there, This is hopefully going to be a really simple answer, I'm just not seeing the proverbial wood for the trees I think. I've got a DataGridCell style in which I want to bind the content of the cell to the source property of an image, here's the XAML I'm using at the moment: <Style x:Key="DataGridImageCellStyle" TargetType="{x:T...

How can I control the SpeedRatio of a Storyboard inside a VisualState?

Given a Storyboard started by the VisualStateManager as part of a ControlTemplate, how would I adjust the SpeedRatio of that animation based on property changes of the control? <ControlTemplate> <Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup> <VisualState> <Storyboard Name="SpinningThing" ...

When to use Path in WPF Binding?

I've seen a lot of WPF Binding examples and have used the feature in a lot of different places in learning MVVM, but something that has seemed quite inconsistent to me is when you specify "Path=" in the binding string as appose to simply typing in the property you want to bind to. For example, what's the functional difference between the...

How to read ListView data into generic List

I have a ListView which is filled by generic list of type MyClass. I can easily bind data from this list into ListView. But I have problems with reading data in opposite direction. This is my class: public class MyClass { public int id { get; set; } public string name { get; set; } } I have also generic list of type MyClass: ...

WPF Button Visiblity

Hi All, I am using MVVM architecture to develop a WPF application... So far everything has been going fine. I have run into an issue with binding visiblity. I want to minimize writing code in the code behind if i can but if it's REQUIRED then I dont mind doing it. I have a ViewModel. THis model exposes a boolean and 2 commands. A con...

DataBinding Problem In ContentTemplate of a TabControl

Hi, I am in a trouble with databinding of the tabControl's Content Template. I have that class public class MainWindowViewModel : INotifyPropertyChanged { string _text1 = "text1"; string _text2 = "text2"; string _text3 = "text3"; public string Text1 { get { ...

WPF changing Background of a label within UserControl using DependencyProperty

Hi. I have a very simple UserControl as shown below. I'm trying to get the background of the Label element to change whenever a property in the control changes, but it's not working: when I change the Selected property on the control instance, the label's background color does not change. Thanks! Code behind: public static readon...

Binding a Property of an object in Item (row) to a DataGridCell Property in WPF DataGrid

Using Release WPF DataGrid I am trying to bind to the property of a CellViewModel (that supports INotifyPropertyChanged of course). I am binding the DataGrid's ItemsSource to an ObservableCollection of type RowViewModel (which is inherited from Dr.WPF's ObservableDictonary) of type CellViewModel and I want bind to a property of a CellVie...

Displaying Data in GridView using Dataset

Hello, I am trying to display a dataset to my ASP.NET application. It seems that when I click the button event, the data is not displaying in the grid. I have a basic page with the following: <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel runat="server" id="Upda...

Binding recursively in a WPF TreeView

I am trying to bind recursively to the children of an item in a TreeView. From what I can see on MSDN HierarchicalDataTemplate is the way to go, but thus far I've only been partially successful. My class: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DocumentText test ...

WPF Custom Attached Property in DataTrigger

I've looked at similar questions here on SO and wasn't able to get a solution, so here's my deal: ** I Have the following class: ** public static class ControlSecurity { public static readonly DependencyProperty IsSecuredProperty = DependencyProperty.RegisterAttached( "IsSecured", typeof (bool), ...

Syntax to bind to the current dataitem's default indexer in WPF?

I have a Listbox with an itemssource set to an ObservableCollection of DataRow. Let's say each DataRow has 5 columns for this example. In the DataTemplate of the ListBox I have 5 textblocks (1 for each column). My question is how can I bind to an indexer of the row to get the columns value? Here is my attempt but nothing displays so I ...

Can't bind to IEnumerable implementation using yield

I have a class encapsulating a bunch of collections. I would like to bind this class to a listbox to display the items in the collections. The class implements IEnumerable. When the listbox is displayed I am expecting the IEnumerable.GetEnumerator method to be called. It is however not when the GetEnumerator method uses the yield keyword...