databinding

DataBinding to reference types

I've got some classes that have properties like this, and they work perfectly because they are very normal: Public Overridable Property CustomerLastName() As String Get Return m_CustomerLastName.Value End Get Set(ByVal Value As String) m_CustomerLastName.Value = Value End Set ...

Prevent property change in databinding and force bound control to show current value

I have Public Overrides Property UID() As String Get Return mUID End Get Set(ByVal value As String) If Me.IsNew Then mUID = value End If OnPropertyChanged("UID") End Set End Property The class implements INotifyPropertyChanged and I...

Why can't I select a null value in a ComboBox?

In WPF, it seems to be impossible to select (with the mouse) a "null" value from a ComboBox. Edit To clarify, this is .NET 3.5 SP1. Here's some code to show what I mean. First, the C# declarations: public class Foo { public Bar Bar { get; set; } } public class Bar { public string Name { get; set; } } Next, my Window1 XAML: ...

All ComboBoxes in a ListBox change when any 1 of them is changed.

I have a ListBox on a form that is bound to an ObservableCollection of a custom type. Within each item there is a ComboBox bound to an enumeration type. When the window loads, all ComboBoxes are defaulted to a certain value. When I change the SelectedItem for any one (from the UI, not from code), all other ComboBoxes change to the sam...

Bind POCO to UserControl

Hi I am in the process of writing my first .net gui. I am wondering if there is some specific way I need to apply to my poco objects for them to be bindable to a usercontrol. I have a few objects but I seem to be unable to bind them to my usercontrol. I read somewhere that they need to implement IBindable but I can't shake the feeling ...

How can I make an Observable Hashset in C# ?

Currently I am using an ObservableCollection within a WPF application, the application is an implementation of Conway's Game of life and works well for about 500 cells but after that it begins to slow down significantly. I originally wrote the application using a HashSet but couldn't find any way to bind the cells to a canvas. Is there a...

How to format string in XAML Setter Value?

I have learned how to format strings in the content attribute of a label like this: <Label Content="{Binding ElementName=theSlider, Path=Value}" ContentStringFormat="The font size is {0}."/> I want to do the same thing in a Setter but "ValueStringFormat" doesn't exist, what is the correct syntax to do what I want to accomplish her...

How do I pass a specific viewmodel object in a button's CommandParam?

I have a simple WPF program using the Master-Detail UI pattern, where the Detail shows the currently selected item of a collection in the Master pane. I'm using MVVM, and each XAML page is backed by a ViewModel object which is set as it's DataContext. Now, I want to add a DELETE button in the Master pane to delete from the master list ...

WPF Linq to SQL applications Some Best practices using binding and master/detail views

Hi, Well i feel im missing something here because im having problems i bet a bunch of people ran into before and i cant find any solutions to this simple scenario. Application Technology: WPF, 3.5(sp1) framework, LINQ to SQL, o/r designer CRUD, Visual studio 2008, C#. Apllication Layout: Main layout conatins a panel to the left holdi...

Why do I have to explicitly set the ItemsSource of a ListView to null before setting it to a new value?

In a particular situation - there is too much code to publish on here - when I try to bind a generic List collection to the ItemsSource of a ListView, nothing happens. The ListView has been bound to a different collection previously. If I set the ListView ItemsSource to null, then the new binding works. I tried to isolate the problem bu...

Deep Binding in Flex

So I have a module in flex in which I add a custom component. I also have a class that handles the data I want to show, lets call this class DataHandler. The DataHandler receives data from the back-end solution and then starts putting the data togheter for my Module and the custom component. When the data is ready it dispatches an eve...

Simple WPF UI databinding

Hi, I'm trying to write a simple WPF app that has two ellipses, joined by a line, like you might see in a network graph. When the ellipses are animated, I just want the joining line to automagically 'stick' to the canvas locations of the two ellipses that the line joins. The XAML is just a canvas: <Window x:Class="UIDataBindingDemo.W...

WPF databinding IsEnabled Property

So I am learning WPF right now, and want to do a simple databind between a bool value, and whether or not a menu item is enabled or not. I have coded it like this: <MenuItem Name="miSaveFile" Header="Save" Click="miSaveFile_Click" IsEnabled="{Binding}"</MenuItem> And in the .cs file I set miSaveFile.DataContext = dataChanged; Fo...

What is the best way to populate a WPF combo box with all items from a given enum?

The title pretty much stays it all. Say I have an enum with four values: public enum CompassHeading { North, South, East, West } What XAML would be required to have a ComboBox be populated with these items? <ComboBox ItemsSource="{Binding WhatGoesHere???}" /> Ideally I wouldn't have to set up C# code for this. Tha...

Binding IList<IMyInterfaceType> doesn't display members of Interfaces that IMyInterface inherits

I'm binding IList to a GridView. IMyInterface looks like public interface IMyInterface: IHasTotalHours, IHasLines { DateTime GoalStartDate { get; set; } DateTime GoalEndDate { get; set; } } I bind an instance to a Grid like this: IList<IMyInterface> instance= GetMyData(); myGrid.DataSource = instance; myGrid.DataBind(); Wh...

How can I bind a Slider value to a Rectable height in Silverlight (works in WPF)?

This code works in WPF but not in Silverlight. Are there any workarounds in Silverlight to enable to me to bind a slider value to element heights? What are the limitations of Silverlight here? ANSWER: Thanks Peter for solving this, for others: here is the solution with online demo and downloadable code. <UserControl x:Class="Second12...

SelectedItem/Index/ValueChanged events not raised when DataSource is Databound on ComboBox

Hi, I am trying to implement the following: Two combo boxes on a Winforms form, the first has a list of parent categories, the second is children of the parent, the child list changes contents depending on the selection in the parent. I'm trying to do this properly using databinding but I'm finding a strange quirk with the ComboBox con...

Binding a custom serializable object to controls so user and load/save preferences

Ok, so having given up on getting the built in .NET configuration system to save/load data about a custom object per user, I have moved to using a serializable object. And, to go a step further, I'd like to bind it to my controls in the options window of my application. Please forgive the length of this question as it has some chunks of...

Eval stacktrace with formatting

I want to take an EventLog entry which has a stack trace in its Message and bind it to a GridView. If I use Eval("Message") and put it in a label or a < p >, it displays, but the stack trace is smashed together. If I Eval it in a TextBox, it keeps its formatting. Is there a way to evaluate this stacktrace value to some sort of literal...

WPF Bind DataTable to repeated user controls

I'm in the process of teaching myself WPF, and I have run into a small issue that I can't find the answer to. My test app allows image files to be dropped into a StackPanel. Once an image is dropped, a new user control is added to the stack, and displays some meta-data about the file. All is working correctly, and I can iterate throug...