wpf-binding

Problems Data Binding to a DependencyProperty on a UserControl

Hi, I have a UserControl that I've added a Dependency Property to: public partial class WordControl : UserControl { // Using a DependencyProperty as the backing store for WordProperty. This enables animation, styling, binding, etc... public static readonly DependencyProperty WordProperty = DependencyProperty.Register(...

Binding in Label.ContentTemplate

In the Xaml below, the first control (the TextBlock by itself) has no problem binding and rendering the value of RecordCount. But in the second control (the Label with the ContentTemplate), the value of RecordCount is not rendered. However, the literal "Cars" is rendered fine. So I know the ContentTemplate is working, but the binding ...

Generating multiple listboxes or stackpanels defining content in XML?

I am looking for an advice on the best technique to generate multiple container boxes of the content with xml in the Page.xaml. It can be stackpanels or listboxes with textblocks and checkboxes in them. I need to have these containers populated on the page with possibility to change position/order of them on the page with drag & drop. An...

[WPF/XAML/C#] Why databinding TwoWay don't work on the text property of a combobx in .net 4.0 ?

Hello, Why databinding TwoWay don't work on the text property of a combobx in .net 4.0 (it's working in .net 3.5) ? My code : I have an xml file like this : <xml> <combobox option="" obs="tralala"> <option value="here" /> <option value="there" /> </combobox> <combobox option="blue" obs=""> <option value="one" /> ...

Using custom class in XAML so it's properties serves as binding destination

First of all sorry for my "pidgin" english, :( Application was built on MVVM pattern. ViewModel exposes its functionality via commands & has special command - DispatchCommand which receives (in CommandParameter) pair of other Command/Parameter & executes received Command with received Parameter. The feature (rather unimportant for topic...

WPF: Databinding a dictionary property

I have a UserControl with a property of type Dictionary, called HighlightedDates. The property holds a set of dates, with a tool tip string for each date, and it works fine when set from code. I want to bind the HighlightedDates property to a view model property, DatesWithNotes, of the same type, using this markup: <MyControls:MyCalen...

CollectionViewSource sorting only the first time it is bound to a source

I'm using a DataGrid bound to a CollectionViewSource (players), itself bound to the currently selected item of a ListBox (levels), each item containing a collection to be sorted/displayed in the DataGrid: <ListBox Name="lstLevel" DisplayMemberPath="Name" IsSynchronizedWithCurrentItem="True" /> ... <!-- DataGrid sou...

WPF: After adding a new row why aren't my bound controls updating?

I'm using wpf drag and drop databinding to datasets. I generate a new datatable row using the AddNew method of the BindingListCollectionView. I set values on the new row and call CommitNew on the BindingListCollectionView. I expect to see my assigned values in the bound controls but they are all blank. If I save the changes to the databa...

UserControl content generated from XML?

I am trying to generate items in wrappanel defined in XML. I am missing something here. I got to the point that I can generate content from xml but it is duplicated. With the code below, I am getting 2 stackpanel with the same content. How to pass the two other values for Person node. Thank you in advance. XML: <?xml version="1.0" enco...

Is there limitation using more than one attached property on Interaction TriggerBase<T>

Hello all, All I'm trying to do is to inherit from the TriggerBase class and add two dependencies properties. However I'm having a strange issue that I can't use RelativeSource not Path, basically nothing. Here is the xaml that won't work ...

page.DataContext not inherited from parent Frame?

I have a Page page in a Frame frame, with frame.DataContext = "foo". (page.Parent as Frame).DataContext is "foo". ok BindingExpression for page.DataContext is null (also forced with ClearValue). ok page.DataContext is null. but I expected "foo"! Why isn't the DataContext inherited? As far as I understand the Frame sandboxes the conte...

WPF XAML Binding

Hi, I have 2 tables Main and Maintest. I am using nhibernate to pull data from database and am joining 2 tables to fetch the fields from both.Now my final object has data from both the tables. Now when I debug my app I can see that I have 2 records from Main and 5 records from Maintest. But somehow I am not able to display records from...

Can I create a KeyBinding for a sequence of keys in WPF?

Is it possible to define key bindings in WPF for a sequence of key presses like the shortcuts in Visual Studio e.g. Ctrl+R, Ctrl+A is run all tests in current solution As far as I can see I can only bind single key combinations like Ctrl+S using the element. Can I bind sequences using this or will I have to manually handle the key pre...

Binding to ItemsSource not working until visual element is manually inspected (MVVM)

I have the Xaml which should basically bind a set of ContextualButtons for a selected tab's viewmodel to the ItemsSource property of the ToolBar. For some reason, this binding is not actually occuring unless I use Snoop to inspect the element manually...It seems that the act of snooping the element is somehow requerying the binding some...

Binding ContextMenu on flattened ViewModel

Hi, suppose the following classes: public class Model { public ObservableCollection<A> Items { get; set; } } public class A { ObservableCollection<B> Data { get; set; } //... some more properties } public class B { //..properties } The model is bound to a RibbonMenu and should also be used in a context menu. The co...

Binding programmatically doesn't work when I add the controls in run-time

Hi, I have two TextBoxes and I want to bind between their Visibility property in run time, The binding works when I add the TextBoxes by Xaml but doesn't work when I add them programmatically, Any help !! public partial class Window1 : Window { TextBox txt1 = new TextBox(); TextBox txt2 = new TextBox(); ...

WPF ObjectContext Attach Detach - Not Working

Hello, I am implementing an ObservableCollection to manage my EF entities. When i want to edit some entity, i create a clone of the entity and i open it up inside a popup window. When the user finishes to edit the cloned entity, i proceed to detach the original entity and then attach the new (cloned and edited) entity. No exception occ...

How to update selected item state in the list box by clicking a button?

I created a listbox menu to browse through content by clicking items in the listbox. I also created ‘back’ and ‘forward’ type of navigation to browse through the same content based on the browsing history. I load content into frame and accessing the browsing history with NavigationCommands.BrowseBack and BrowseForward Properties. It is w...

C# WPF Switch Resource Programmatically

Hi, i`m trying to design a dialog window which will display different messages depending on what case will be true. so for example when i have a <CustomDialog Content="{Binding Path=Name}"/> is there a possibility to change the Binding Path=Name to Path=Whatever or how do you implement something like that ? When the Control should us...

WPF Newbie Grid Binding Question

I'm new to WPF. I have been been playing around with binding data to a grid. However the example below never calls the method that will be used to populate the grid. What do I need to do to make this go? <Window x:Class="DataGridView.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:local="clr-nam...