databinding

WPF/Silverlight DataBinding to interface property (with hidden implementation)

I have the following (C#) code namespace A { public interface IX { bool Prop { get; set; } } class X : IX { public bool Prop { ... } } // hidden implementation of IX } namespace B { .. A.IX x = ...; object.DataContext = x; object.SetBinding(SomeDependencyProperty, new Binding("Prop")); .. } So I have a hidden implementa...

Binding to an ObservableCollection of UserControls

Simple Silverlight question: I have an ObservableCollection<MyObject> in my viewmodel. Every MyObject has a Label property. If I bind a ListBox to the collection and set DisplayMemberPath to Label, or set the ItemTemplate to a TextBlock that binds the Text property to Label, all works as expected. If I change MyObject so it derives from...

Distinguish UI change to variable from code-behind change

Like the title says I am trying to architecture into my application a way to distinguish the source of a variable change, either from UI or code-behind. My problem is that I need to trigger some action after a property changed its value, but I only need to do this when the change comes from the UI because otherwise I don-t want to perfo...

WPF Binding.Stringformat ignored

With .NET 3.5 SP 1 I checked out this blog and followed instructions, however the StringFormat parameter still gets ignored. Any possible reasons? To be sure: the datatype that are involved are DateTime, double, int. So the formatting SHOULD work, but it's not. Any clues why? EDIT: here's the code! <Label Content="{Binding Path=TotalHo...

Where do I define dependency properties shared by the detail views in a master-detail MVVM WPF scenario?

I can think of two ways to implement dependency properties that are shared between the detail views: Store them in the master view model and add data bindings to the detail view models when they are created, and bind to them in the detail view. Don't store them in the view models at all, and use FindAncestor to bind directly to propert...

DropDownListFor and relating my lambda to my ViewModel

After googling for a while I'm still drawing a blank here. I'm trying to use a ViewModel to pull and provide a dictionary to a drop down list inside a strongly typed View: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="EveNotebook.ViewModels.CorporationJoinViewModel" %> ... <%: Html.DropDownLis...

Bug with DataBinding in WPF Host in Winforms?

Hi Guys, I've spent far too much time with this and can't find the mistake. Maybe I'm missing something very obvious or I may have just found a bug in the WPF Element Host for Winforms. I am binding a ListView to a ObeservableList that lives on my ProductListViewModel. I'm trying to implement searching for the ListView with the gen...

XmlDataSource with XPath - can I get the raw data in code?

If an ASP.NET form has an XmlDataSource on it, and in code I am setting the XPath filter, e.g: xmlExample.XPath = String.Format("data/reasons/reason[@text='{0}']/details/",someValue); ... can I then get the result of that XPath filtering in code, or do I have to bind to a control to find out the results? In other words, is it p...

WPF: Problem with SelectedItem for ComboBox

XAML: <ComboBox Height="27" Margin="124,0,30,116" Name="cbProductDefaultVatRate" VerticalAlignment="Bottom" ItemsSource="{Binding}"> <ComboBox.ItemTemplate> <DataTemplate> <Label Height="26" Content="{Binding Path=Value}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> Set Data for cbProductD...

Lazy Loading wpf Combobox items

I have an IEnumerable<> which lazy loads it's data. I want to just set a Combobox's ItemsSource to the IEnumerable, but when I do it goes and loads all the data anyway (which removes the point of lazy loading). I've tried it with Linq-To-Sql as well since it seems to be a similar theory and it also loads all the data. Is there an easy ...

Winforms, databinding, Listbox and textbox

Hi dear friends, I have a ListBox (MyListBox) on my screen, and a Textbox (MyTextBox). The ListBox is filled with a List(Of T), which are all custom items. Now I try to do this: The ListBox' datasource is the List(Of T). Now when an Item changes I want the textbox to be updated to a particular property of the selected item in my Li...

Databinding in ASP.NET User Control

What is the best way to create a data bound ASP.NET user control? I have a user control that contains a drop down list and three label controls. I would like to data bind the drop down list, and have the label controls display different properties of the data source. I have Googled for an example of IDataSource and User Control, but ...

Current ways to do data binding in .NET 3.5 with C# 3.0 and WinForms

Hello Everyone, I have an existing C# 3.0 WinForms project with .NET 3.5 that talks to a MySQL database. I would like to use data binding (I'm new to this, so I've been doing all of the UI updates manually) to simplify things. I followed a link from this question to this article which mentions using a DataSet but also follows up with ...

Can i bind an the datasource Index in a repeater/grid

Hi All, I have a repeater.. and in my repeater i have a link that fires some JS. I would like to pass the itemIndex of the datasource in the JS. Is there some way to do this without using OnItemBound or OnItemCreated?? like.. <a href="#" onclick="dosomestuff(<%# this.item.index %>); return false;">Add Stuff</a> i know the syntax i...

WPF Conditional Binding. Button.IsEnabled to SelectedIndex >= 0

I want to bind a buttons IsEnabled property to (myObject.SelectedIndex >= 0).... isn't there a simple way to do this in the xaml (without having to do crazy things to any underlying objects)? I haven't really seen a good example. Honestly, I wish this was as easy as Flex 3 ... I.E.: <mx:Button enabled="{dataGrid.SelectedIndex >= 0}" .....

Combobox INotifyPropertyChanged event not raised!!!

I created a combobox and set observable collection as the itemsource and implemented INotifyPropertyChanged on the observable collection item. Even after that, when I select different item in the combobox, the OnPropertyChange method is not invoked. I think I am not making the binding properly. Could any one please correct me/ suggest m...

WPF DataGrid and Avalon TimePicker binding problem

I'm using a the WPF DataGrid from the wpf toolkit and a TimePicker from AvalonControlsLibrary to insert a collection of TimeSpans. My problem is that bindings are not working inside the DataGrid, and I have no clue of why this isn't working. Here is my setup: I have the following XAML: <Window x:Class="TestMainWindow" xmlns="http://sc...

WPF: Binding to converted object failed!

Maybe the title was not quite exact since I am not sure about how to describe it. I have a user control named NSLTextBlock, below is the definition of NSLTextBlock: public partial class NSLTextBlock: UserControl { public override void OnApplyTemplate() { base.OnApplyTemplate(); } public object HighlightMatchCase ...

Databinding to individual properties of the main Dataobject

This is my ViewModel Code: vb: Public Property Doctor() As Doctor Get Return _objDoctor End Get Set(ByVal Value As Doctor) _objDoctor = Value OnPropertyChanged("Doctor") End Set End Property Public Property AddDate() As Nullable(Of DateTime) Get ...

How can I bind another DependencyProperty to the IsChecked Property of a CheckBox?

Here's an example of what I'm trying to accomplish: <Window x:Class="CheckBoxBinding.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <StackPanel> <CheckBox Name="myCheckBox">this</CheckBox> ...