wpf-binding

Binding to Element's Visibility value

I have a checkable DropDownButton and a Grid. I want to bind Button's IsChecked parameter with grid's Visibility value. If (Visibility == Visible) IsCheked = true I've tried to do like that: IsChecked="{Binding ElementName=UsersDockWindow, Path=IsVisible}" but it didn't work, cause IsVisible is readOnly property. ...

Adding an Image to ListView in WPF like this ... ?

I'm gonna create a ListView in WPF like the below image http://www.picfront.org/d/7xuv I mean I wanna add an image beside of Gravatar label within Name column. Would it be OK if you guided me ? Edit: The image is output of a method. The method makes the image from a base-64 string. ...

Silverlight 3 Binding to the Current Item in a Collection

The Binding syntax, {Binding /}, works in WPF but does not work at all in Silverlight 3: <ContentControl Content="{Binding MyCollection}"> <ContentControl.ContentTemplate> <DataTemplate> <ContentControl Content="{Binding /}" /> </DataTemplate> </ContentControl.ContentTemplate> </ContentControl> What...

Binding Image.Source to String in WPF ?

I have below XAML code : <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" DataContext="{Binding RelativeSource={RelativeSource Self}}" WindowStartupLocation="CenterScreen" Title="Window1" Height="300" Wid...

WPF Combobox binding Question

I have a 2 Table. Product ProductName CategoryID Category ID CategoryName I'm filling combobox to table named 'category'. Code Product currentProduct=datacontext.products.FirstOrDefault(); this.datacontext=currentProduct; combobox1.Itemssource=datacontext.categories; XAML <Textbox Text="{Binding Path=ProductName}"></Textbox> ...

WPF - simple relative path - FindAncestor

In the XAML below the ToolTip correctly binds to RelativeSource Self. However, I can't for the life of me work out how to get the TextBlock in the commented block to refer to SelectedItem.Description <Controls:RadComboBoxWithCommand x:Name="cmbPacking" Grid.Row="2" Grid.C...

Evaluate ContentControl without rendering to screen

I have a datagrid and I'm writing a method to search through it to find some text. Practically all of my columns use a DataTemplateSelector, so in my search, I need to be able to take a DataTemplate, apply it to a ContentControl, and then find a TextBlock to get the text to see if it matches my search criteria. I'm trying the following b...

WPF binding to current class property

Hello, I have a problem that i cant solve :( I have a user control (xaml file and cs file) in xaml it's like: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxm...

Call bindings for DependencyObject when DependencyProperites are changed

Is there a way to notify a DependencyObject's bindinigs when the inner DependencyProperties have changed? For example, I have this class: public class BackgroundDef : DependencyObject { public static readonly DependencyProperty Color1Property = DependencyProperty.Register("Color1", typeof(Color), ...

Locating binding errors

I'm dealing with a large WPF application that is outputting a large number of binding errors. A typical error looks like this: System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=Horizon...

Databinding between 2 Dependency Properties

Hello, I'm trying to do databinding between 2 Dependency Properties. I guess this should be quite easy, anyways I just don't get it. I already googled but I couldn't really find out what I'm doing wrong. I'm trying to bind the ControlPointProperty to the QuadraticBezierSegment.Point1Property, however it doesn't work. Thanks for any hint...

Problem in DataBinding an Enum using dictionary approach to a combobox in WPF.

I have a Dictionary which is binded to a combobox. I have used dictionary to provide spaces in enum. public enum Option {Enter_Value, Select_Value}; Dictionary<Option,string> Options; <ComboBox x:Name="optionComboBox" SelectionChanged="optionComboBox_SelectionChanged" ...

Data Binding: multiple sources for one property

Hello, I want to bind one property to multiple sources. My reason for this are things like this: midpoint=point2.X - point1.X; //depends on two sources! How could this be realised? As far as I know it's not directly possible out-of-the-box? ...

How to explicitly select the row in ListView in WPF?

I have a ListView in which one of the column contains combo box. I have binded the selectedItem of a Listview, so that I get the current object (selected row ) in the listview. When I do any operation in a combo box like selection change then the listview row ( in which that combo box belongs) is not selected be default and hence my ...

WPF - Changing an image resource in a datatemplate programmatically

I have a ListBox showing some objects associated each with some files. I also have a ListView of images linked to the listbox's selection. I would like the listview to show an icon corresponding to the filetype (an image for video, image, doc etc...) of each file with the filename below. I can figure out all the code except how to bind t...

Item rendered via a DataTemplate with any Background Brush renders selection coloring behind item.

I have a ListBox which uses a DataTemplate to render databound items. The XAML for the datatemplate is as follows: <DataTemplate x:Key="NameResultTemplate"> <WrapPanel x:Name="PersonResultWrapper" Margin="0" Orientation="Vertical" Background="{Binding Converter={StaticResource NameResultToColor}, Mode=OneWay}" > ...

In WPF, how do I update the object that my custom property is bound to?

I have a custom property that works perfectly, except when it's bound to an object. The reason is that once the following code is executed: base.SetValue(ValueProperty, value); ... then my control is no longer bound. I know this because calling: base.GetBindingExpression(ValueProperty); ... returns the binding object perfectly - U...

Add an extra row in a ListBox with XAML.

I have a ListBox with radiobutton on the horizontal line. Number of radiobuttons is optional. The text for each radiobutton is taken from a list of the model. Which radiobutton that is selected will be determined by the property SelectedOption. If none is select it shall be set to -1. The problem is that I wish that in addition to the ch...

WPF Binding to DataRow Columns

Hi, I've taken some sample code from http://sweux.com/blogs/smoura/index.php/wpf/2009/06/15/wpf-toolkit-datagrid-part-iv-templatecolumns-and-row-grouping/ that provides grouping of data in a WPF DataGrid. I'm modifying the example to use a DataTable instead of a Collection of entities. My problem is in translating a binding declaration...

WPF: Is it possible to add or modify bindings via styles or something similar?

I'm still learning the WPF ropes, so if the following question is trivial or my approach wrong-headed, please do speak up... I'm trying to reduce boilerplate and it sounds like styles are a common way to do so. In particular: I've got a bunch of fairly mundane data-entry fields. The controls for these fields have various properties I...