wpf-binding

C#/WPF Retrieving images from database and displaying them

Hi, I need to retrieve the url of the image from the database, bind it to a business object, convert it into a bitmap image and map it into the resource dictionary. The resource dictionary is used as a library and I cannot change it. The database consists of one table that has three columns: id, name, url. It is the SQL CE 3.5 local dat...

How to control the Visibility of a textbox with radio button "IsChecked" property?

How to control the Visibility of a textbox with radio button "IsChecked" property? I have a Two textbox's let say txtbox1 and txtbox2 and I want to bind the visibily of both these textboxes based on the radio button IsChecked property. Below is the XAML code I am trying with: <RadioButton x:Name="radioBtn" ...

WPF: Databinding to parameterized properties

Given this class/property, how would I write a WPF data binding expression to get myToken.DataItem("Phone")? Class Token Public Property DataItem(ByVal name As String) As Object Get If m_DataPoints.ContainsKey(name) Then Return m_DataPoints(name) Else Return Nothing End Get Set(ByVal value As Obje...

WPF Reverse Binding OneWayToSource

I have a custom control which has the following dependency property public static readonly DependencyProperty PrintCommandProperty = DependencyProperty.Register( "PrintCommand", typeof(ICommand), typeof(ExportPrintGridControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits)); publ...

WPF: Data binding with code

How do I use data-binding from code (C# or VB)? This is what I have so far, but it is displaying Binding.ToString instead of m_Rep.FirstName. Public ReadOnly Property TabCaption As Object Get Return New Label With {.Foreground = Brushes.Black, .Content = New Binding("FirstName"), .DataContext = m_Rep} End Get End Prope...

How to Bind Slider's Thumbnail size change to its value

I would like to know how can I use xaml code without extantional code? I want to create a Slider, that its Thumbnail change its size while moving up or down the slider's value. We know that we can use C# Converter is there a way to do that using xaml only. Thanks. ScreenShot [URL=http://img69.imageshack.us/i/wpfbind.jpg/][IMG]http://...

Mixing OneTime and TwoWay binding

Suppose having this kind of CLR-objects: public class Foo { ... public Bar { get; private set; } } public class Bar: INotifyPropertyChanged { public string Baz { get {...} set {...} } } Now I have a Window, with the DataContext bound to an instance of Foo. Within this Window I do: <TextBox Text={Binding Bar.Baz} /> Bec...

intercept RelativeSource FindAncestor

I have a WPF application which runs as a excel plugin, it has its visual tree like so Excel ElementHost WPF UserControl WPF ribbon bar control Now any controls sitting on the WPF ribbon bar control are not enabled when the plugin is loaded within excel. See error below System.Windows.Data Error: 4 : Cannot find source for bin...

WPF Templates error - "Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception."

I've just started experimenting with WPF templates vs. styles and I'm not sure what I'm doing wrong. The goal below is to alternate the colors of the options in the menu. The code works fine with just the , but when I copy and paste/rename it for the second segment of "MenuChoiceOdd" I get the following error: > Provide value on 'Syst...

What is the difference between DataTemplate and DataContext in WPF?

I can set the relationship between View Model and view through following DataContext syntax: <UserControl.DataContext> <view_model:MainMenuModel /> </UserControl.DataContext> And I can also set the relationship between View Model and view through following DataTemplate syntax: <DataTemplate DataType="{x:Type viewMode...

ParentBinding vs. ParentBindingBase?

What are the differences between the two propeties of System.Windows.Data.BindingExpression ParentBinding and ParentBindingBase? ...

How do I bind to a RowDefinition's height?

In this example code, I'm trying to offset the Grid's Canvas position by the height of one of its rows. Does anyone see what I might be doing wrong? As you can see, I tried moving the binding lower in the xaml file, just in case the RowDefinitions needed to be defined first. Either way, it doesn't seem to matter because Canvas.Top is...

DataBinding 2 ComboBoxes wpf

Hi I need to build a form where I have 2 comboBoxes . Select country and you get the cities of that country. I m new to wpf so help me as I not sure what I am missing. At the moment It doesnt even populate it. Any help suggestions really appreaciated! This is what I have done: public partial class App : Application { prot...

Question on MVVM pattern on WPF ?

I have a user control let say UC1 . This user control have viewmodel UC1_vm. In the usercontrol UC1 I have a canvas in which drawing curve logic is implemented. This drawing curve logic is based on the data points property in the view model ( UC1_vm). The data points property inside the view model change with different condition. The...

Query on MVVM pattern in WPF?

I am implementing a MVVM pattern in my WPF application. My application main window is divided into four parts: Main Menu On the Top Outlook Navigation Control on the Left. A List View on the Middle. Another List view on the bottom. The Navigation control shows different setting (configuration) controls in the Tab items. All the fo...

Possible to use Bindings only for the SourceChanged event?

Basically I want to use the WPF Binding framework to "observe" a property in the data context, and when that value changes to call an event handler. I do not actually want to bind it to any target. Sounds simple but from what I can see Binding is too coupled (to the visual tree and various other bits) to be able to use it flexibly. Any...

Treeview databinding problem associating an icon to each node

Hi all I am new to wpf and need to use the treeview in a real world application and was building something simple beforehand to get a feel. I am loading countries and cities and dont have to be loaded on demand for now I cannot seem to associate an icon for the city and an icon for the country. Created a folder called images and success...

Datatable binding to a form is not working

Hi All i am having a form which are having 4 lables and these lables value are displayed in the 4 textboxs, i am using MVVM and binding these textboxs with the Datatble which is coming through the typed dataset not the problem here is when i add a new row in the datatable with default values of columns and update ui by calling onpropert...

WPF Datagrid binding to DataTable with complex type

Hi all, I have a class that contains data from some model. This class has metadata along with the actual value. class ServerValue { public int SomeId {get;} public int SomeOtherId {get;} public DateTime LastChanged {get;} public object Value {get;set;} // this lets me show the value, but how do i update it from...

How To Raise Property Changed events on a Dependency Property?

OK, so I have this control with two properties. One of these is a DependencyProperty, the other is an "alias" to the first one. What I need to be able to do is raise the PropertyChanged event for the second one (the alias) when the first one is changed. NOTE: I am using DependencyObjects, not INotifyPropertyChanged (tried that, didn't ...