databinding

Why don't OneTime and OneWay databinding work with TextBlock's Text property

In Silverlight 3: I've got an object that implements INotifyPropertyChanged I've got a TextBlock with the Text property bound to a property on my object. However, the property changes and fires the PropertyChanged event, but the TextBlock control never displays the value. If I change the Mode to TwoWay, it works, but this doesn't make...

WPF Listbox Images from a database

Hi guys! (How long have we been using OpenIDs? I don't seem to have one connected to any provider and no FAQ on the planet seems to tell you what to do when you lose your OpenID. I've had to create a new account. Argh!) I'm trying to fill a (carousel) listbox from a database, but I can't get the images to display. Every single example ...

WPF checkbox IsChecked property does not change according to binding value

here is my code: xaml side: I use a data template to bind with item "dataType1" <DataTemplate DataType="{x:Type dataType1}"> <WrapPanel> <CheckBox IsChecked="{Binding Path=IsChecked, Mode=TwoWay}" Command="{Binding Path=CheckedCommand} /> <TextBlock Text="{Binding Path=ItemName, Mode=OneWay}" /> </WrapPanel> </D...

Flex: Changing Control Properties based on contents of a Databinding event

I'm trying to set up a form that presents a combobox when an ArrayCollection it's bound to has several items, and doesn't present one when it's empty or only has one item. I've tried doing this by creating this class, but unfortunately, the data provider I've bound to is never not empty at the time the setter executes. Is there a differe...

WPF ToggleButton IsChecked binding issue

Hi, I am trying to create a situation where one or none of a grouping of two ToggleButtons can be on at any time. The problem that I have is if I change the state of the backing variable the UI state does not update. I do have INotifyPropertyChanged implimented. I've created my ToggleButtons like this: <ToggleButton IsChecked...

How can I bind to a sub-property of a specific item in a List<T>?

How can I create a binding to a sub-property of a specific element in a list? I've created a class that exposes an IList property: public IList<VideoChannel> VideoChannels { get { const int NumVideoChannels = 4; return (new List<VideoChannel>(NumVideoChannels) { new VideoChannel("Ch...

SelectedValue which is invalid because it does not exist in the list of items

RE-POSTING WITH MORE ACCURATE DATA: I encounter this problem repeatedly, and haven't a clue what is causing it. I get an exception in the DataBind: "SelectedValue which is invalid because it does not exist in the list of items". Here are some important pieces of information: 1) I reload listOrgs periodically when the underlying data ha...

strange behaviour in wpf datatemplate and property

I have a datatemplate that displays buttons in a stackpanel, whenever a user clicks at the button, the button is said to glow, so I have written the necessary datatrigger in the template and a boolean condition in the property that I'm binding too. Here are the details below <DataTemplate x:Key="ActionItemsTemplate" DataType="ActionItem...

In a WPF binding, how can I manipulate the data I'm binding, like, say concat two strings together?

I'd really like to be able to do some manipulation to the stuff I'm binding. Similar to being able to call String.Format() in a <%#%> tag in ASP.Net. For example, assuming this is the type I'm binding: class User { public string FirstName { get; set; } public string LastName { get; set; } public int Age { get; set; } } and t...

How to databind to a dropdown list of user defined types?

I have a dropdown list containing the days of the week - Monday to Sunday. It is populated with a user defined type of two values that map the numeric day of the week to it's name. Public Structure WeekDays Public ID As Integer Public Text As String Public Overrides Function ToString() As String Return Me.Text End Fun...

Data-bind a column to a collection

I have multiple Users, each with a collection of Tasks. public class User { public string Name { get; set; } public IEnumerable<Task> Tasks { get; set; } } public class Task { public string Name { get; set; } } What I would like to do in Silverlight is have each User represented as a column, with Tasks represented as item...

Is there an MVVM-friendly way to use the WebBrowser control in WPF?

Thanks to this question (click me!), I have the Source property of my WebBrowser binding correctly to my ViewModel. Now I'd like to achieve two more goals: Get the IsEnabled property of my Back and Forward buttons to correctly bind to the CanGoBack and CanGoForward properties of the WebBrowser. Figure out how to call the GoForward() a...

MVVM: Binding to ListBox.SelectedItem?

How do I bind a view model property to the ListBox.SelectedItem property? I have created a simple MVVM demo to try to figure this one out. My view model has these properties: private ObservableCollection<DisneyCharacter> p_DisneyCharacters; public ObservableCollection<DisneyCharacter> DisneyCharacters { get { return p_DisneyCharact...

How do I bind to this custom dependency property?

I have a DependencyProperty in my custom UserControl that looks like this: public static readonly DependencyProperty ColumnWidthProperty = DependencyProperty.Register("ColumnWidth", typeof(int), typeof(CallBoard), new PropertyMetadata(150)); public int ColumnWidth { get { return (int)GetValue(ColumnWidthProperty); } s...

OnExpanded event for any item in a treeview.

I'd like to get an event for any expansion of a treeviewitem in my treeview. The reason for this, a bit unrelated to the original question: I am creating a tree that relates closely to an xml file tree, but I am allowing an include element in the xml so the tree can go across multiple files. I'd like to set the itemssource property of...

How can I get a TextBlock to literally say "{Binding}"?

In XAML, if you insert <TextBlock Text="Hello World" /> You will see the words "Hello World". If you insert <TextBlock Text="{Binding}" /> it will trigger the data binding functionality. But what if I really wanted the display text to be "{Binding}"?" Are there the equivalent of escape characters in XAML strings? Or is my only s...

How do I bind to the first item in an ArrayCollection?

My application works with the MVC model. The model contains a Bindable class (BindableItemsClass) which contains an ArrayCollection. I want to bind some stuff in the view to the first item in the ArrayCollection of the Bindable class (hence the property 'firstItem'). The problem is that when the setter 'set firstItem(value:Object)' is u...

Add empty entry to combobox bound to entity list

I use a ComboBox which is bound to a List<> of Entities. How can I add a "Not selected" entry to the combobox? Adding null to the list results in empty combobox. ...

Why does data binding break in OneWay mode ?

Here's a little XAML fragment. You will see <StackPanel> <TextBox x:Name="txtValue">250</TextBox> <Slider x:Name="slide" Value="{Binding ElementName=txtValue, Path=Text, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Minimum="0" Maximum="500"></Slider> </StackPanel> when you change the textbox valu...

Bind to a property's property

I have a List (Of MyObject) binding to a GridView in the Page_Load event. MyObject has a child object as a property, ChildObject which also has a property itself, ChildProperty. In my GridView, I would like to bind one of the fields to ChildProperty, but doing something like: <asp:boundfield datafield="ChildObject.ChildProperty" /> ...