wpf-binding

Dynamically creating checkboxes from database using MVVM

Hi, How to create dynamic checkboxes at run time from the databases values using MVVM pattern. I have set all the table columns as get;set; properties in Model. But not getting how to create the checkboxes using MVVM and where to put what means where to put database connections and functions for that and how to bind the dynamically crea...

WPF: Dynamically binding a list to (some of) an object's properties

I have a collection of objects stored in a CollectionViewSource and bound to a DataGrid. I want to display a 'detail view' of the object currently selected in the DataGrid. I can obtain the current object using CollectionViewSource.View.CurrentItem. MyClass{ [IsImportant] AProperty{} AnotherProperty{} [IsImportant] ...

wpf ItemsControl binding problem

I bind to a ItemsControl in my codebehind: ColumnVisibilityItems.DataContext = gc.ColumnVisibility; where ColumnVisibility is a ObservableCollection, also tried it with dictionary.. my markup <ItemsControl x:Name="ColumnVisibilityItems"> <Label Content="{Binding Path=Name}" /> </I...

WPF Binding: how to make property being changed when the property of it's property changed

I created class: class StorageBase { public Queue<Slices> Slices {get;set;} } and wpf custom control which has dependency property Storage of type StorageBase: public StorageBase Storage { get { return (StorageBase)GetValue(StorageProperty); } set { SetValue(StorageProperty, value); } } ...

Unable to use IMultiValueConverter in WPF to allow metric or imperial input

I would like to create a C# WPF form that collects measurements of equipment, but some users insit on using feet and inches for measurements while other (younger) users do everything in metric. The database stores everything in meters, and I figured this was a perfect place to use a IMultiValueConverter. Each form has a DependencyProper...

Comboboxes in GridView are synchronized instead of bound to the value from the database

I have tried to set up combo boxes in the gridview but all the combo boxes have the same value in them instead of the value from the database. I am using entity framework and WPF. There is a parent child relationship between two tables but the source for the combo box is a separate table with names and IDs for tags. I have been looking a...

How to dynamically bind parent element

I'm dynamically creating multiple expandable panel in silverlight. Every panel contains textbox. I need to bind this textbox to parent expandable panel header property. How to do it dynamically? ...

WPF Binding to specific property

I'm new to DataBinding but would like to accomplish the following: I have a ViewModel which has a collection of objects: CollectionOfStuff Each object Stuff has some properties: Name, Value. In my View, I have a StackPanel with some TextBlocks. I would like to bind the TextBlock's Text property to a specific property. ( I would like t...

WPF - Static Binding - Error shows up but everything works fine

Hello Ok, I have a specific custom behavior for my MenuItems. So I bind the windows from my static class FormsResource and it works perfectly. But, very often, I get an exception "Exception has been thrown by the target of an invocation" in the 3 lines where I have "{Binding Source={x:Static local:foo}}" I can't see the inner exception, ...

Problem getting custom content in a TabItem visible.

I have a custom ItemsControl (WorKArea) that marks all items it has into a WorkSheet instance. I have a style for the ItemsControl that uses a TabControl to show the content. Every sheet creates a tab. The style is: <Style TargetType="{x:Type local:WorkArea}"> <Setter Property="Template"> <Setter.Value> <Control...

Binding in WPF style causes inexplicable "Cannot find governing FrameworkElement" error

I have an ItemsControl that displays a bunch rectangles. Each rectangle needs to be offset upward and to the left. So, I created a RectangleStyle that uses bindings to set the width, height, X translation, and Y translation for a rectangle. The width and height bindings are working fine, but I'm getting the following error for the Tran...

Binding DataGridComboBoxColumn ItemsSource to RelativeSource FindAncestor doesn't work

Hello, I'm trying to use WPFToolkit's DataGrid control (and C#/.Net 3.5) to display a ComboBox per record. With the below code, the ComboBoxes show up but their drop-downs contain no items: <wpftkit:DataGrid ItemsSource="{Binding TransactionToEdit.SisterTransactions}" AutoGenerateColumns="False"> <wpftkit:DataGrid.Columns> ...

Setting XAML property value to user control

I have a user control in WPF which i want the text of one of it's labels to be read from the XAML where it is used. Hence.. My User Control: <UserControl x:Class="muc"> <Label Foreground="#FF7800" FontSize="20" FontWeight="Bold"> <Label.Content> <Binding ElementName="TestName" Path="." />...

Simple WPF 4 Question: DataGrid of List of Objects is showing no records

This is driving me nuts. I have a datagrid in WPF that is not populating with records at runtime. Here is the XAML. I've done this before in Silverlight although I am a newbie and can't quite figure out what is missing. <DataGrid AutoGenerateColumns="True" Height="335" HorizontalAlignment="Left" Name="DataGrid1" VerticalAlignment="To...

DataGridTemplateColumn doesn't support direct content?

I know I did this in Silverlight... In WPF 4 I am trying to put controls in a DataGridTemplateColumn element in DataGrid XAML I can't add anything to it and I get errors saying it doesn't support direct content. WTF? I want to put in maybe a hyperlink, textboxes, a button, etc. I can't even add a canvas. ...

Template Binding to background and foreground colors?

I'm building a simple ControlTemplate for a Button. I want to draw a 2 color gradient, and bind the two colors so I don't need to hard code them in the template. But since Background and Foreground are Brushes and not just Colors, I'm not sure this will work. Can anyone tell me if there is a good way to do this? it seems simple enoug...

set XmlDataProvider source without saving file

in my browser wpf application i use databinding to xml that comes from my database. to bind it the better way i use the XmlDataProvider. in the beginning i declare <Grid.DataContext> <XmlDataProvider x:Name="listdataxml" XPath="EssenceList/Essence" Source="model.xml"/> </Grid.DataContext> but later i need to point it to a new XDo...

WPF corelating Multibindings and Converter's values[]

My XAML is as follows <Button.IsEnabled > <MultiBinding Converter="{StaticResource IsEnabledConverter}" > <Binding Path="aaa"/> <Binding Path="bbb"/> <Binding Path="ccc"/> <Binding Path="ddd"/> <Binding Path="eee"/> <Binding Path="fff"/> <Binding Path="ggg"/> <Binding P...

Why Microsoft add Design-time Attributes (d:DataContext ...) and do not use the current DataContext instead

In WPF-XAML, determining DataContext at designtime vs runtime. Why do we have to add "d:DataContext" while we already have set the "DataContext" ? Why Microsoft introduced DesignTime attributes (code that we have to add, a little bit complex) when it could already be determined automatically by itself using "DataContext" attribute. The ...

Custom control binding to a collection within a property

HI, I stuggeling with the databinding with in a custom control I've got some properties within my custom control. public static DependencyProperty TitleProperty; public static DependencyProperty PageDictionaryProperty; public string Title { get { return (string)base.GetValue(TitleProperty);...