wpf-binding

WPF: Alternatives to Grid for displaying data?

What are the alternatives to Grid for displaying repeating data in WPF? For example, how would I show customers as a list of business cards? ...

WPF: What is the right base class for collections used in data binding?

I am building an object model with strongly typed collection classes (e.g. CustomerCollection). I want to support full two-way binding on both the collection itself and all of the data models in the collection. For the models it seems like INotifyPropertyChanged is the right way to wire up the models. But what inferface/base class shoul...

WPF: Detect when selected item changes

I have a control that is data-bound to a list box. All of the bound properties are being updated correctly. However, the control needs to know when the selected item changes so that it can do some other cleanup. Is there an event that covers this? ...

WPF databinding - an interesting problem

I have a database with a table that records data coming from various sources. 3 columns 'Source' 'Value' 'Timestamp' e.g. source1 21 '11:03' source6 22 '11:03' source9 456 '11:03' The table is updated 2 to 3 times a second. Each Value may or may not change. Each 'Source' value is displayed in a seperate label or text box on the s...

WPF: How do I apply custom formatting to a ListView?

My ListView is petty simple: <ListView ItemsSource="{Binding Path=ActiveCounters}"> <ListView.View> <GridView> <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}" /> <GridViewColumn Header="Value" DisplayMemberBinding="{Binding Path=Value}" /> <GridViewColumn Heade...

WPF: inserting data into ListBox placed in ListBoxItem

Hi, I'm trying to create fancy looking Listbox. ListBoxItems are supposed to expand after being selected, but the problem is, they're also supposed to contain another ListBox filled with some details about particular item and I have no idea how to put some data into it. I've tried both accessing it from C# code and binding it in XAML bu...

Limit the number of rows displayed in Items control

Is there a way to limit the number of rows that get displayed in items control. ? I have a observable collection of strings which are bound to Items control. I want to limit the number of rows to display to only one. The collection can have more than one. Thanks, ...

WPF Binding Enum to Command Parameters

I am trying to bind a Enum to CommandParameters of a button. This cannot be static due to the fact that the button occurs in a ItemsControl. Here is the Datatemplate: <DataTemplate> <Button Command="{Binding MyCommand}" CommandParameters="{Binding MyEnumParameter}" Text="{Binding MyText}" /> </DataTemplate> I am not sure what I n...

WPF - Have a list source defined at runtime but still have sample data for design time

I have some ListBoxes in my WPF app. I would like to be able to view how the design looks with out having to run the app. But I still want to be able to bind to ItemsSource to my View Model. I know I saw a blog post on how to do this, but I cannot seem to find it now. To reiterate, I want dummy data at design time, but real data at ...

IObservable<T> and INotifyPropertyChanged - is there a connection...

I understand the IObservable & IObserver are implementations of the observer pattern and can be used in similiar circumstances to .Net events. I was wondering if there is any relationship to INotifyPropertyChanged? I currently use INotifyPropertyChanged for data binding in winforms & WPF applications and was wondering if I'll be able t...

WPF - Temporarily Stop Data Binding (databinding)

I have a textbox that is bound (oneway) to a datatable that updates a couple of time a second. So the textbox value continually reflects changes in datatable. When I enter the textbox to manually set a value, the binding causes the value to continually be overwritten. How do I stop this? When I have entred a value (textbox lost focus) I...

WPF Programmatic Databinding

I am writing an application that uses a GridView. I am dynamically creating GridViewColumns and setting their CellTemplate.VisualTree property to a FrameworkElementFactory that creates a StackPanel containing some other elements. The DataContext of the StackPanel is being bound to an item contained in a collection in the dataitem. Basica...

WPF - Bind a List<T> as the contents of a WrapPanel

Is is possible to make the contents(children) of a WrapPanel to be bound to a dependency property? What I am thinking is having a dependency property that is of type List and then define a template for MyClass. Then have the WrapPanel display them. I know this is much easier done with a list box, but due to other constraints, I need t...

Get a Bound Object from a control

I have the following xaml: <ItemsControl> <ItemsControl.ItemTemplate> <DataTemplate> <Button Content="{Binding Name}"></Button> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> In my code I have an event that gives me access to the button. How can I take the button object and get the ob...

Creating a Window.Title Attached Property

I have a Window shell that is basically: <Window> <ContentPresenter Content="{Binding}" /> </Window> Injected into the ContentPresenter at run-time are UserControls. What I want to be able to do is write: <UserControl Window.Title="The title for my window"> [...] </UserControl> So that the Window title is updated using the User...

How can I add dynamic controls in an empty grid in wpf using xml

I have a combo-box, where the user is going to choose an option. According to that option I want to fill an empty grid with my definition in xml. How can i do it? <Content xmlns="" > <Category Title="LayoutOptions"> <Sample Path="samps\border_samp.xaml" Title="My new Textbox" Description="This is a new textbox." > ...

WPF - Why are changes to an object for a simple data-binding not reflected back to the target in the main window?

I am currently learning WPF (C#) and have taken the following simple data binding example from a text book which I am trying to get working. The example displays a simple window containing a name and age textbox and a Birthday button. The name and age that are display are represented in a Person object. When the birthday button is cli...

Binding WPF Toolkit DataGrid ComboBox column to Linq-to-Sql collection after Window loads and connection changes?

Hi All, I am a beginner to MVVM. The main window uses a stock DataGrid from the WPF Toolkit. It has one View Model and relies only on DataContext_Changed event handler in the .xaml.cs file. The main window's DataContext is the View Model. I am attempting to bind the ItemsSource property of a DataGridComboBoxColumn to a CLR property, "...

How to aggregate bindings in Silverlight UserControl

Imagine a UserControl containing some sort of ItemsControl. The UserControl as a whole has a DataContext, but you also need to expose the ItemsSource of the ItemsControl. I have tried all manner of arrangements, and eventually passed a DomainDataSource as a UserControl dependency property named DDS, and bound the ItemsControl like this:...

WPF ListBox Databinding & Events

My problem is rather simple. I have a ListBox, containing Thumnails (Image) <ListBox Name="ListBox_Thumbnails" ItemsSource="{Binding}" DataContext="{Binding Source= {StaticResource ThumbnailListSource}}" Width="120" HorizontalAlignment="Left" Margin="-1,26,0,54"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> ...