wpf-binding

Binding a Viewbox to a Canvas

I'm trying to bind a Viewbox to Canvas that is created dynamically like so: <ListBox.ItemTemplate> <DataTemplate> <DockPanel> <Viewbox> <ContentPresenter Content="{Binding Canvas}"/> </Viewbox> </DockPanel> </D...

Good practice or bad practice

Hi, i am new to WPF and i have one question(the first one actually, more to come) Is it better to add some logic, for example the bindings for the window, in xaml or in the code behind. ...

Bind command to X-button of window title bar

My WPF maintenance window have a toolbar with a button "Exit"; a CommandExit is bind with this button. The CommandExit perform some checks before exit. Now, if I click to close button of the window (x-button of title bar), this checks are ignored. How can I do to bind CommandExit to window x-button? ...

Master Details and collectionViewSource in separate views cannot make it work.

Hi all, I really cannot seem to make/understand how it works with separate views It all works fine if a bundle all together in a single window. I have a list of Countries-Cities-etc... When you select a country it should load it's cities. Works So I bind 3 listboxes successfully using collection sources and no codebehind more or les...

Unable to display data in a WPF datagrid that has a DataView instance as the items source

I am using a DataGrid object from the WPF toolkit. I am binding the DataGrid object to the default view of a DataTable instance as declared in the following code: WeatherGrid.ItemsSource = weatherDataTable.DefaultView; weatherDataTable has three columns. The first column is defined to contain a string data type. The other two colum...

multi threading wpf

Hey, I'm using web refernce call in new working thread in my application as follow: Thread callRunner = new Thread(delegate() { _mediator.IncomingCallDetails(phoneNumber); }); callRunner.Start() ; the _mediator calls the web refernce and replay to the caller in event as follow: void IncomingCallComplited(IncomingCallEve...

What is the safest way of databinding to an element in another xaml file in WPF

I have an application which shows a Tree where can select nodes of the tree and add them to a list. To keep the code clean I have moved the TreeView into it's own UserControl(I use this tree in several places) and xaml file. To add a node to the list I have an 'add' button. However I want to gray-out this 'add' button when none of the tr...

WPF Conditional Binding. Button.IsEnabled to SelectedIndex >= 0

I want to bind a buttons IsEnabled property to (myObject.SelectedIndex >= 0).... isn't there a simple way to do this in the xaml (without having to do crazy things to any underlying objects)? I haven't really seen a good example. Honestly, I wish this was as easy as Flex 3 ... I.E.: <mx:Button enabled="{dataGrid.SelectedIndex >= 0}" .....

Binding across multiple DispatcherObjects

Here is a really tricky scenario I have been confronted with. I have a static helper class that contains some dependency properties used as binding sources. My main Window binds to these properties to determine some visual aspects. Recently we have added the ability to measure the progress of long-running operations with a progress bar w...

Show animation when databound property changess to *any* value

Is there a way to attach a trigger (and a subsequent animation) to a control which has a property databound, and have that trigger fire when the value of that databound property changes (to ANY value). I don't care what value it is, I just want to show a notification when the value changes to something else. Might be very obvious, but I...

WPF Binding Question - Change Label Text based on Modifier Key Control

I have a context menu, that I'd like to change the Header based on whether the Control Key is pressed or not. Right now I have, <MenuItem Header="Send To"> <MenuItem ... /> <MenuItem ... /> </MenuItem> I'd like based on the Control Key being down to be, <MenuItem Header="Move To"> <MenuItem ... /> <MenuItem ... /> </MenuItem...

Bind ListBox to List<Image>

I need to bind a List of Images to a list box. My code being: <ListBox x:Name="lstImages"> <ListBox.ItemTemplate> <DataTemplate DataType="{x:Type Image}"> <StackPanel> <Image Source="{Binding Path=UnassignedImages}"></Image> </StackPanel>...

How can I use data binding in WPF to create a new user control for each element in a list?

I have a list of objects. For each item in the list, I want to create a new user control bound to that item. From what I've read, doing this programmatically is bad practice with WPF (as well as less than straightforward), so I should use data binding as a solution instead. The problem is, I can't figure out how to do this. I don't know ...

Remove binding to FrameworkElementFactory

I am currently creating a datatemplate to display data in a listview control in a specific manner and bound to the data. This works fine. But I need to be able to remove the bindings when the screen is closed and control is being disposed. How can I do this? I am thinking of just passing null as the second parameter of SetBinding and no...

WPF binding and pointers

hey guys, I have a WPF application that contains windows with few user controls and Coordinator object. the window and all its user controls pointing to an object, which instace is in the Coordinator, by thier DataContext. the problem is that I want to change this object (e.g. create new object()) in the Coordinator but I want all the da...

Shorter Binding expression with validation

Hi, I'm repeating same binding parameters for every textbox and they're quite long strings (which is not good for many reasons). And I'm wondering if there's a way to make them shorter? For instance all my controls on forms are using the following binding template: Text="{Binding SourceProperty, UpdateSourceTrigger=PropertyChanged, Va...

How to setup bindings to user controls in separate directories

to date I have created and setup bindings and dependencies between controls and other objects when they are located within the same directory or within the same xaml document. Now I have created a usercontrol which is located in a directory of my project called "Controls" this control is then loaded within the main xaml document using ...

WPF: Binding and Commands

My Customer has a property called SaveCommand. My form is data-bound to an instance of the Customer object. Using XAML, how would I bind Customer.SaveCommand to the form's save button? ...

WPF: Is there a way to bind to a method using PyBinding?

Using standard rules, it is a royal pain to data-bind to a method. So I'm wondering if it possible to use PyBinding to do a easy one-way bind. ...

WPF: How do I debug binding errors?

I'm getting this in my output Window: System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ListBoxItem' (Name=''); target pro...