databinding

FormView ConvertEmptyStringToNull and binding

I'm using a FormView with an ObjectDataSource and binding using <%# Bind("WhateverProp") %> - and all of my nullable columns are coming back with default values of the type in them. It appears that the FormView object doesn't have a ConvertEmtpyStringToNull property like the other binding containers do. I've found articles suggesting...

Use of Container.DataItem in an ItemTemplate

I'm not able to get this working and I can't figure out why. <ItemTemplate> <% if (Field(((DataRowView)(Container.DataItem)), "Video File") != "") { %> <a href='upload/images/<%# Field(((DataRowView)(Container.DataItem)), "Video File")%>'>Download Link</a> <% } else { %> <embed height="14" width="661" name="plugin" src="<%# Content...

With WPF, how to collapse a TextBlock depending on the content of its child TextBlock?

Hello, I have to display a big list of properties/values. My issue is that there aren't values for all these properties, so I would like NOT to display these in that case. It will be easier to understand my problem with some code: <StackPanel DataContext=...> <TextBlock>Info1:<TextBlock Text={Binding Path=Info1} /></TextBlock> <TextBl...

Bind multiple TextBoxes to one struct in WPF

How do i bind two TextBox objects to a System.Windows.Size struct? The binding only has to work in this direction: (textBox1.Text + textBox2.Text) => (Size) After a user inserts the width and height in the TextBoxes on the UI the Size object should be created. XAML: <TextBox Name="textBox_Width" Text="{Binding ???}" /> <TextBox Name=...

Debugging Silverlight Bindings

I have a binding in Silverlight that is causing my application to exit. An unhandled exception is not throw; I just get a white screen. I am not seeing anything from the binding engine in the output window. Does anyone have any ideas for debugging this issue? ...

Declarative derived properties for mutable models in Java

Is there a framework for synchronizing properties of POJOs? For example, I want to express (in some high-level, declarative form) that foo.text = bar.text + baz.text or foo.y = (max(bars, y)).y without having to register property change, element add and remove listeners on values and (especially) collections, which are repetitive and err...

GridView in ASP.NET 2.0

How can I populate an editable Grid with data from different tables from MSSQL Server'05 writing a code behind function??? I have used: Dim conn As New SqlConnection(conn_web) Dim objCmd As New SqlDataAdapter(sql, conn) Dim oDS As New DataSet objCmd.Fill(oDS, "TAB") Dim dt As DataTable = oDS.Tables(0) Dim rowC...

Show Images in WPF ListBox

Hi All, I'm trying to display images stored in MSSql Db as varbinary, when execute my code it just hangs itself Code is as follows... XAML <Window x:Class="ImageList.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namesp...

Winforms listbox not updating when bound data changes

The image below shows how my code works. When I press button2 the listbox is updated, but not when I press button1. Why? Is the problem threading related? If it is, where should I add the call to (Begin)Invoke? One interesting thing to note is that if I first press button1 and then button2 the data generated by the button1 click is s...

Getting a reference to the ViewModel from an IValueConverter

Is there a clean and/or an accepted standard way of referring back to the ViewModel from an IValueConverter, or does that break the MVVM pattern? Basically, I want to convert bound data in the UI based on other properties of the ViewModel. I guess this is the same question as how do you refer back to the Window/Page from an IValueConve...

Setting Focus on new Items in Items Control

I've got a ListBox which is getting new items added to it through Databinding (i.e. something is getting added to the list and the box is updating to include the new item). The items in the list box are editable data templates, so the question is: How do I set the focus to the first field in the template when a new item is added? I've ...

How to resize columns of DataGrid bound to List<T>, not DataSet?

I'm trying to use a System.Windows.Forms.DataGrid control in my Compact Framework 3.5 Window Mobile Professional 6 SDK based project to show some properties of objects of type Something by binding the DataGrid to a List<SomethingWrapper> instance like this: public class SomethingWrapper { private Something data; public SomethingWr...

How to bind to a WPF dependency property when the datacontext of the page is used for other bindings?

How to bind to a WPF dependency property when the datacontext of the page is used for other bindings? (Simple question) ...

How do I bind to the SelectedItem property in a ControlTemplate?

Consider the following Control/Template <my:ExpandingListBox Margin="0,2,0,0" x:Name="TagSearchListBox"> <my:ExpandingListBox.Template> <ControlTemplate TargetType="{x:Type my:ExpandingListBox}"> <Border Name="MyBorder" BorderThickness="2" BorderBrush="Black"> <Grid> <TextBlock...

Silverlight/WPF Many to Many List of Checkboxes Binding

I have an entities model with a many to many relationship. For simiplicity, lets assume its a car entity and a feature(cd player, moonroof, etc.) entity. I have a Silverlight/WPF form in which you edit the car entity. I would like to have the list of possible features (everything in the features table) be a list of checkboxes. That par...

WPF bind control size

I have a StackPanel with a list of custom user controlls that I would like to resize. I would like the user to be able to drag a slider and scale the control size up and down. Is there a way to bind the control width to a slider value? Something similar to: <MyControl Width="{Binding Path=SizeSlider.SelectedValue}"/> Is this possible...

How to propagate errors & exceptions that occur during WPF data binding?

Every so often I find that I have accidentally broken data binding in my application. Either by renaming a property and not renaming it in the XAML or by a property throwing an exception for some reason. By default data binding errors are logged to debug output and exceptions that are thrown are caught and suppressed. Is there an easy...

How does one go about debugging databinding issues in MVVM?

I have rebuilt Josh Smith's CommandSink example from scratch and my version runs without error except that my command buttons are grayed out. I assume this is because there is something somewhere not set correctly so that the commands never get set to CanExecute = true or at some point get set to CanExecute = false. But since the databi...

How do I bind the Binding.Path property to underlying data?

I'm trying to bind a TextBlock's Text property in a very dynamic way. I need to get the Path from an underlying object. Here's the DataTemplate: <DataTemplate DataType={x:Type local:DummyClass}> <TextBlock Text={Binding Path=???} /> </DataTemplate> The DummyClass object has a property named "FieldValuePath" - the path that needs to...

How can I emulate ErrorProvider in .NET Compact Framework?

Since there is no ErrorProvider class in .NETCF, how can I implement similar functionality (not necessarily exactly like ErrorProvider)? I am using all the regular databinding constructs to bind controls to a datatable, using the DataRow.RowError property and DataRow.SetColumnError method, but I can't find events on any of DataTable, Bi...