databinding

C# simple DataBinding question

I am trying to make a (very) simple Data Binding test, but it doesnt work as I expected... Say I have the following classes: // this class represents some kind of data producer public class DataSourceClass { public string Data { get; set; } public DataSourceClass() { } } //this form holds the TextBox c...

How do I do conditional logic within an ASP.NET DataRepeater control?

I'm binding my DataRepeater control to a table that has many columns. I'd like to only display a subset of those, depending on what is populated. How/where should I do my contitional tests within a dataRepeater? This is the code within my itemtemplate: <% if (0= (DataBinder.Eval(Container.DataItem, "first").ToString().Length)) { ...

Master-Detail via ComboBox in C#?

I have a form showing the details of a client (various controls), along with their orders (in a DataGridView). I am trying to add a ComboBox to let the user select one of the client's orders and display the items associated with it in a separate DataGridView. However, I cannot work out which DataSource/DataBindings I need for either th...

Self-hosted WCF service: How to access the object(s) implementing the service contract from the hosting application?

I am self-hosting a WCF service in a WPF client. I want to show the data the service receives in the user interface. Every time some data is received the user interface should be updated. The code in "App.xaml.cs" looks like private ServiceHost _host = new ServiceHost(typeof(MyService)); private void Application_Startup(object...

Populate one combobox based on selection of another

I am learning wpf mvvm and have been struggling with what I feel is probably simple but have not been able to resolve on my own. What I want is to be able to select an item in a populated combobox and then populate another combobox based on that selection. I can't seem to get the second combobox loaded in response to a selection. I'...

Scroll bar greyed out when a Data Grid View is updated but not visable.

I have a custom control that is basically a DataGridView docked inside a split panel with a rich text box on the other half. This control is docked in a tab page in my main program. Here is some relevent code public LogReader() { InitializeComponent(); using (var conn = new SqlConnection(ConnectionString)) using (var ada ...

Repeater within a Gridview - Repeater only pulling from the last gridview ID(causing each repeater to be the same)

I have a gridview that displays all trips - within that gridview I have a repeater that displays the countries visited during that trip (one to many). My repeater is suppose to grap the tripID and then populate the datasource, which populates the repeater. Unfortunately, my repeater is just being populated with the last tripID specified...

Replacing a ListView's ItemsSource Without Loosing SelectedItem

Hello, I'm data-binding a ListView to a collection that comes from a service layer. In response to events, the view model associated with the ListView refreshes the ListView's data. In order to retrieve updated data, the vm retrieves a new collection instance from the service layer. Items in this collection are Equals() but not Referenc...

Cross-thread operation exception when worker thread adds to BindingList

I have a worker thread that needs to add items to a BindingList. However, the BindingList is databound to a DataGridView. So, when I try to add to the list, I get an InvalidOperationException (Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.) Normally for this exception you would ...

How to set SelectedValue of DropDownList in GridView EditTemplate

I am trying to do this as asked earlier. The only difference that I found is additional List item that was included in above code. I tried to use AppendDataBoundItems=true but it is still not working. I also want to set the its default value to the value that was being displayed in label of itemtemplate i.e. DropDownList's SelectedValue...

WPF/XAML: How to change a borders background with a colorpicker

Hello everybody, i have a xaml resource file with some definitions of datatemplates. In one datatemplate i have a border background bound to a property of its dataobject. I also have a colorpicker user control which is part of the contextmenu of the border. Now i'm trying to bind the dependency property "CustomColor" of the colorpicke...

sorting rows in databound datagridview

Greetings. I have a DataGridGiew, bound to a object datasource - List<SomeType>. I want to sort it by string representations of fields values (ignoring real types) with grid header clicks. I have many grids, that are bound to many lists of different object types. How can i do this as fast as possible? Thanks in advance p.s. framework 2...

Data Binding in WPF control doesn't pick the new data from IPropertyChangedNotify call.

Project Overview Basically I was creating WPF application using MVVM pattern. However I had a thread which was updating my Data Model, so ViewModel, had to be notified about these changed and I needed a Notification mechanism in my Model. That would make my app make propagating notifications from one class to another, so I decided to Ha...

WPF: Command parameter for a delete command in a list

In my viewmodel, I have a list (ObservableCollection) containing items. In the view, this list is displayed in an ItemsControl. In each row, there is a "Delete" button. I want the command behind the button to remove the item from the list. <ItemsControl ItemsSource="{Binding myList}"> <ItemsControl.ItemTemplate> ... ...

WPF, property bound to dependent ComboBox always gives initial value

I have a ComboBox that needs to depend on the value of another ComboBox. This part already works, with the dependent ComboBox refreshing when a new value is chosen in the independent ComboBox: <!-- Independent --> <ComboBox Height="23" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="2" x:Name="cbo_product" VerticalAlignm...

WPF UserControl not rendering at design time

I am relatively new to WPF, so I apologize if I am missing something basic. I have a user control where I declare dependency properties named PT1x, PT1y, PT2x, PT2y: Private _pt1x as double = 9 Public Property PT1x As Double Get Return GetValue(PT1xProperty) End Get Private Set(ByVal value As ...

Databinding multiple controls to a single LINQ query

I have a LINQ query I wish to run and drop the result into a var or IQueryable. However, I'm binding the result to multiple (4 to 10) controls and only want the query to run once. When I just put the result into all the datasource values, the query runs for every control and the controls (comboboxes, for example), change selectedvalue...

Specifying a WPF's databound attribute's design-time value in XAML

I'm playing around with a Canvas inside of a Viewbox, and unforunately, the only way to see the elements in the Canvas, I have to assign it a Height and Width. However, the problem is that my Height and Width values come from my ViewModel via databinding. I know that Blend gets around this with the d: designer namespace, which is set t...

textbox - textbinding in WPF

Hi Let's say that I have a custom WPF control and couple of textboxes on it. In code behind of my custom control I have couple of properties which are references to objects in other control. For example I have a sth like this public MyClass myObject { get { return MyObject } } MyClass have ...

Disable databinding in MXML

When the Flex SDK converts MXML to actionscript it generates a lot of databinding code. Sometimes, however, I don't want to bind a variable, for example if I know the variable will not change. I can't seem to find a work around in Flex to disable the autogenerated databinding. Also, I was hoping this might also help with some of the...