databinding

WPF ContextMenu with bound items: Items.Count == 0 in ContextMenuOpening event

I have a ContextMenu with the ItemsSource bound to the selected item of a list view, like this: <ContextMenu ItemsSource="{Binding Path=PlacementTarget.SelectedItem, RelativeSource={RelativeSource Self}, Converter={StaticResource possibleConverter}}"/> The possibleConverter enumerates all possible values for a property of the the ...

Memory leak on CollectionView.View.Refresh

I have defined my binding thus: <TreeView ItemsSource="{Binding UsersView.View}" ItemTemplate="{StaticResource MyDataTemplate}" /> The CollectionViewSource is defined thus: private ObservableCollection<UserData> users; public CollectionViewSource UsersView{get;set;} UsersView=new CollectionViewSource{Source=users}; Us...

Bind Grid.Row / Grid.Column inside a DataTemplate

Hope this is not a dupe. I would like to be able to do the following in XAML: <DataTemplate DataType="{x:Type TestApp:ButtonVM}"> <Button Grid.Column="{Binding GridColumn}" Grid.Row="{Binding GridRow}" Content="{Binding Path=Info}" /> </DataTemplate> The Cont...

Two gridviews one RowDataBound

I got two gridviews in the same page, which basically displays the same type of data (different amount, same structure, same design...). There is a lot of conditions inside the RowDataBound that are all the same (99%), so I wanted to reduce the code. Use it once. I thought I'd use the same RowDataBound. It works all right. However, I n...

How to maintain ComboBox.SelectedItem reference when DataSource is resorted?

This really seems like a bug to me, but perhaps some databinding gurus can enlighten me? (My WinForms databinding knowledge is quite limited.) I have a ComboBox bound to a sorted DataView. When the properties of the items in the DataView change such that items are resorted, the SelectedItem in my ComboBox does not keep in-sync. It seems...

DataSet.HasChanges is true even immediately after TableAdapter.Update is run

I've got some legacy dataset code which I'm updating. I'm attempting to determine if the dataset has changes to it so I can properly prompt for a save request. However myDataset.HasChanges() always returns true. In my save method I've edited the code to determine when the dataset get's changes and made the code like this: 1. myBindingS...

Databind List Of Objects To A WinForms DataGridView, But Not Show Certain Public Properties

I'm not even sure if i'm doing this correctly. But basically I have a list of objects that are built out of a class. From there, I am binding the list to a datagrid view that is on a Windows Form (C#) From there, it shows all the public properties of the object, in the datagrid view. However there is some properties that i still need ac...

Implement INotifyPropertyChanged on DataContext in WPF?

When doing databinding does one have to implement INotifyPropertyChanged on the datacontext in WPF? ...

how to bind a winforms to a field ?

I use winforms to develop application, I want to know how can I use data binding to bind two radio button to a database field ? And if bind to a database field is too complicated, then can I save the value manually while leave other field bind to textbox and automatically update the value? ...

WPF binding only inside XAML (simple question)

Why this works <myToolTip:UserControl1> <TextBlock Text="{Binding Path=TestString, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type myToolTip:UserControl1}}}"/> </myToolTip:UserControl1> BUT this does not <myToolTip:UserControl1 x:Name="userControl"> <TextBlock Text="{Binding Path=TestString, ElementName=userCo...

In WPF how to define a Data template in case of enum?

I have a Enum defined as Type public Enum **Type** { OneType, TwoType, ThreeType }; Now I bind Type to a drop down Ribbon Control Drop Down Menu in a Ribbon Control that displays each menu with a MenuName with corresponding Image. ( I am using Syncfusion Ribbon Control ). I want that each enum type like ( OneType ) has dat...

Get the current bounded object in a ListView's ItemTemplate

I want to be able to get the current bound object in the ItemTemplate of a ListView control. Here's an example of what I want to do: <asp:ListView ID="UserList" runat="server"> <LayoutTemplate> <asp:PlaceHolder ID="itemPlaceHolder" runat="server" /> </LayoutTemplate> <ItemTemplate> //How can I get the curren...

C# WPF DataBind boolean

I have been using this website to learn a lot about C# for a while, but this is my first time posting a question. I look forward to hearing back from some of the seasoned C# veterans! I have been working on a C# 4.0 WPF project and need to figure out how to databind a boolean value. I have a reference to my Application.Current object ...

Silverlight 4.0: MultiDataTrigger

Is there a way just like multidatatrigger behavior of WPF also implemented in Silverlight 4.0? OR Another workaround which behaves like multidatatrigger? ...

WPF Listbox - Empty List Display Message

Can anyone suggest the best way to display a Textblock (with a text such as "List Empty") so that it's visibility is bound to the Items.Count. I have tried the following code and can't get it to work, so think that I must be doing it wrong. <ListBox x:Name="lstItems" ItemsSource="{Binding ListItems}"> </ListBox> <T...

C# function called after dependency property have been set

My code currently looks like this: private Foo myFoo; public Foo CurrentFoo { get { return myFoo; } set { SetFoo(value); } } private void SetFoo(Foo newFoo) { // Do stuff // Here be dragons myFoo = newFoo; } To be able to bind it in XAML/WPF I need to turn Foo into a dependency property: public static Dependenc...

Using a WPF toolkit DatePicker as a parameter to an ObjectDataProvider used as an itemssource (cont)

Continuing from the original question, when the ObjectDataProvider binds from the specified Method, a number of BindingExceptions are raised similar to the following: System.Windows.Data Error: 39 : BindingExpression path error: 'xxx' property not found on 'object' ''Object' (HashCode=15292788)'. BindingExpression:Path=xxx; DataIte...

TwoWay Binding to ListBox SelectedItem on more than one list box in WPF

I have a scenario where I have a globally available Properties window (similar to the Properties window in Visual Studio), which is bound to a SelectedObject property of my model. I have a number of different ways to browse and select objects, so my first attempt was to bind them to SelectedObject directly. For example: <ListBox Items...

How to set focus to a brand new TextBox which was created as a result of a databinding in WPF?

Hi everyone, I have a WPF ItemsControl that is bound to an ObservableCollection. The XAML: <ItemsControl Name="mItemsControl"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBox Text="{Binding Mode=OneWay}"></TextBox> </DataTemplate> </ItemsControl.ItemTemplate> </...

WPF Update Source Trigger Implementation

I have a custom object Foo with a boolean property called Flagged and when someone successfully types something in a text box it changes flagged to true and updates another textblock on the screen with some text. The problem is I can get it to work on loading the initial data but nothing happens when the user successfully types somethin...