wpf-binding

WPF: How do I get different templates based on a list-item's type?

I heard that I could create a collection of mixed types and have a different Data Template for each type. How woudl I do that for a ListBox? ...

WPF ComboBox Binding to non string object

I'm using MVVM (MVVM Light Toolkit) and have a property on the view model which exposes a list of objects. The objects contain two properties, both strings, which correlate to an abbreviation and a description. I want the ComboBox to expose the pairing as "abbreviation - description". If I use a data template, it does this easily. I ...

XAML Binding to complex value objects

I have a complex value object class that has 1) a number or read-only properties; 2) a private constructor; and 3) a number of static singleton instance properties [so the properties of a ComplexValueObject never change and an individual value is instantiated once in the application's lifecycle]. public class ComplexValueClass { ...

Binding TreeView selection to ViewModel

So I have a TreeView that looks something like this: <TreeView Name="elementTreeView" ItemsSource="{Binding Elements}" Width="Auto" SelectedValuePath="Path" /> I also have a TextBlock defined as follows: <TextBlock Text="{Binding ElementName=elementTreeView, P...

HttpWebRequest socket operation during WPF binding in a property getter

In a property getter of a C# class I am doing a HTTP GET using HttpWebRequest to some https address. WPF's property binding seems to choke on this. If I try to access the property in a simple method e.g. Button_Clicked, it works perfectly. If I use WPF binding to access the same property, the app seems to be blocked on a socket's recv() ...

WPF Dependency Property Coercion binding issues

I have both VS2008 and VS2010 installed, and I see a very strange behavior In VS2008, I have a simple WPF app: <TextBox x:Name="textbox" Text="{Binding Path=MyProperty,Mode=TwoWay}"></TextBox> and public Window1() { InitializeComponent(); DataContext = this; } public string MyProperty { get { return (string)GetValue(MyP...

Binding expression failing.

My output window is flooded with binding expression failures like : "Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.UserControl', AncestorLevel='1''. BindingExpression:Path=DataContext.CurrentActivationObjectType; DataItem=null; target element is 'StackPanel' (Name='');...

Binding to XMLDataProvider in Code Behind

Hello, i have a problem moving a XMLDataprovider Binding with XPath from Xaml to code behind. Labels.xml <?xml version="1.0" encoding="utf-8" ?> <Labels> <btnOne Label="Button1"/> <btnTwo Label="Button2"/> </Labels> MainWindow.xaml <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x...

XAML Binding to a CollectionViewSource property on a ViewModel

I have a simple ViewModel like: public class MainViewModel { ObservableCollection<Project> _projects; public MainViewModel() { // Fill _projects from DB here... ProjectList.Source = _projects; ProjectList.Filter = ...; } public CollectionViewSource ProjectList { get; set; } } I set the window's...

how to bind to the results of a query in WPF

I have a query that hits a service and returns the results back to me as an indexed collection static void QueryActivities() { QueryClient qc = new QueryClient("BasicHttpBinding_IQuery"); QueryFilter filter = new QueryFilter(); filter.CallForService = false; var result = qc.GetFilteredActivityIndex(filter); result.Cl...

WPF MVVM Chart change axes

I'm new to WPF and MVVM. I'm struggling to determine the best way to change the view of a chart. That is, initially a chart might have the axes: X - ID, Y - Length, and then after the user changes the view (either via lisbox, radiobutton, etc) the chart would display the information: X - Length, Y - ID, and after a third change by the us...

WPF - Binding a variable in an already bound ListBox?

I really don't know how to title this question, but I need some help with binding to a ListBox. I have an object, that contains (among other information) 2 properties that need to be bound in one ListBox. One of these is an ObservableCollection of objects, called Layers, and the other property holds an enum value of either Point, Line o...

Binding ContentControl to an ObservableCollection if Count == 1

Hello, how can I bind the Content of a ContentControl to an ObservableCollection. The control should show an object as content only if the ObservableColelction contains exactly one object (the object to be shown). Thanks, Walter ...

data binding on properties confusion

I have a wpf tabitem whose data context is set to my object 'Product'. All the controls on this form get their data from 'Product' object. I have a listview whose ItemsSource property is set to a list in my object 'Product.DetailsList'. Listview columns are bound to object properties in 'Product.DetailsList' Up till here everything work...

why when setting <ContentControl Content="{Binding CurrentViewModel}" i get the ToString() of the ViewModel name?

Hi , I'm using mvvm-light. i;m trying to create an application with one side command button and the other side place holder for views. when i try to create the view by command i get the ToString name of the ViewModel. For Example : LU.ViewModel.ChannelsViewModel What i'm missing? here is my code: mainWindow New Channel <...

How do I turn off a custom IValueConverter at design time?

How do I turn off a custom IValueConverter at design time? Basically I want to write this: Public Class MethodBinder Implements IValueConverter Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert ...

WPF Binding issues

I have WPF window which binds a local Dependency property to a property of my usercontrol. So now I see the value which the window gave me in my usercontrol. I achieve this by setting DataContext of window to the window itself Now once the window is loaded i set the DataContext of usercontrol to a ViewModel class, and at some point of t...

WPF: Binding to ObservableCollection in ControlTemplate is not updated

I created a ControlTemplate for my custom control MyControl. MyControl derives from System.Windows.Controls.Control and defines the following property public ObservableCollection<MyControl> Children{ get; protected set; }. To display the nested child controls I am using an ItemsControl (StackPanel) which is surrounded by a GroupBox. If...

WPF ComboBox Object Binding - not updating DataContext Object

Hello, I have the following scenario: 1 class called 'Widget' with the properties: ID, Code, Description 1 class called 'MyWidget' with a property: m_Widget As Widget 1 ComboBox The ComboBox has a List(Of Widget) set as the ItemSource. I create an instance of 'MyWidget' named MyWidget1 and I set the property values of the m_Widget to ...

Databinding to Classmember of Classmember

Hello, I need some help about WPF and Databinding. Let's say I have a ClassA with a member of ClassB. ClassB has again a member, maybe an int: ClassB { public int MemberOfB { get; set; } } ClassA { private ClassB _theB; public ClassB MemberOfA { get {return _theB;} set { _theB = value...