databinding

How to format data bound text in a label

I have a label control that is bound to a object collection like lblUser.DataBindings.Add(new Binding("Text", UserCollection, "UserName")); This works fine and the Username on the label. But I need to display the Username as User Name : UserName How do I add the static "User Name :" part in front of the bound value on the label ? ...

WPF, WVVM, Databinding, and ResourceDictionaries

I've got a View (MainView) which contains a kind of main content area (MainContent). The View is backed by a corresponding ViewModel (MainViewModel). The main content changes, of course, based on the current state of the application and is represented in the ViewModel as a property (CurrentPrimaryViewModel). The content of MainContent...

Binding to Image Property

Let's say I have the following dummy class: public class Foo { public Image MyImage { get; set; } } and I have the following in some XAML <Image Source="{Binding Foo.MyImage}"/> If I understand this correctly, this doesn't work because Source is expecting a URI string value fo...

Resolve this error

Hi, I have a WPF UserControl that i am using in a Windows Form using ElementHost. I am passing data from my Winform to my UserControl using a ListCollectionView. In my UserControl i have a method setdataSource where i am setting the datasource. But i keep getting this message in the output window when i debug my program "System.Wind...

Strange issue binding to ComboBox where the display value sometimes shows up blank

I'm seeing a strange issue when binding to ComboBox where the display value sometimes shows up blank. The case is repeatable however and happens the second time a dialog opened from another parent form. If the parent form is closed and reopened then the first time it's child dialog is opened the contained WPF ComboBox shows the display p...

XAML: Refer to StaticResource in plain XAML? (without markup extension)

I am setting a validation rule on a series of textboxes. I'd rather not create a new instance of my custom validation rule for each TextBox... <Window.Resources> <my:IsIntegerRule x:Key="IsIntegerRule"/> </Window.Resources> ... ... <TextBox> <TextBox.Text> <Binding XPath="@num" UpdateSourceTrigger="PropertyChanged" Mode="T...

DataBinding with entityframework bug

Hi, I have an application which consists of simple schema of DB: Networks 1-->* Shops i use entityframework (Default EntityObject Code Generator) with winforms, i use DataBinding to a grid to CUD these entities, i have : DbObjectModelContainer _context = new DbObjectModelContainer(); _context.ContextOptions.LazyLoadingEnable...

Why DataBinding is not working?

Why DataBinding is not working? <TextBox Text="{Binding Path=local:MainWindow.SearchPlayer, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> this is my class: public partial class MainWindow : Window { private Store store = new Store(); private string _searchPlayer; public string SearchPlayer ...

Silverlight XAML databinding to a field

Hi, in the following code, <riaControls:DomainDataSource AutoLoad="False" d:DesignData="{d:DesignInstance my:V_FinanceCalculatorDefaultValues, CreateList=true}" Height="0" LoadedData="v_FinanceCalculatorDefaultValuesDomainDataSource_LoadedData" Name="v_FinanceCalculatorDefaultValuesDomainDataSource" QueryName="GetV_FinanceCalculatorDe...

Invoking BindingList changed event when an item's property changes value

Hi. I have a ListBox that is bound to a ViewModel property of type BindingList(Of MyItem) (lets call it MyTrueList). The MyTrueList property actually looks at another BindingList(Of MyItem) and returns a list where MyItem.MyProperty = true. MyItem implements INotifyPropertyChanged. I also have a button whose event changes the selected i...

WPF - Reload an a collection (with 'new') without rebinding controls

Imagine the following: class Repository { private ObservableCollection<ModelClass> _allEntries; public ObservableCollection<ModelClass> AllEntries { get { return _allEntries; } set { _allEntries = value; } } public void RefreshDataFromDB() { _all = new ObservableCollection(GetMyData()); //...

Binding storyboard animation values

I have an enum on a viewmodel which represents one of 5 colors, and I am using a ValueConverter to convert these values into actual colors. Specifically it's for the color of each listbox item's background to change to as it is hovered over. I have a custom control with a visual state manager and a mouseover group which uses a SplineCo...

Is it possible to bind the liistbox selected value to mediaelement source wpf

Hi All, The listbox contain images and the object assigned to the listbox have corresponding wmv file path. How to bind the selected path the the mediaelement through {binding}. Geetha. ...

Changing the appearance of collection of items according to a single property in XAML

I have 4 buttons in grid which datacontext is set to an object which has property that indicates what button should be enabled (it's enumerable). Currenty I have done this in code-behind so that when that specific property changes, it disables all but one depending on the value. It works, but I really don't like to put stuff like this t...

What is the DataContext of a DependencyObject in Silverlight4?

I have read that SL4 introduces the ability to data bind properties on objects that derive from DependencyObjects, where previously data-binding only worked on FrameworkElements or FrameworkContentElements. However, I am not clear on how the binding source is determined when binding properties of DependencyObjects. In the case of Frame...

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...

How to speed up WPF DataGrid?

The background: I have arbitrary query that is executed and then I fetch data -- array of records = arrays of objects. I would like to view them using DataGrid. The problem: It does not feel that app is responsive enough. Switching from query to query is slow, it takes around 1-2 seconds to switch, and there are only ~20 records to disp...

Should a DropDownList within a CompositeControl remember selected item?

Given the following public class MyControl : CompositeControl { private DropDownList myList; protected override void CreateChildControls() { base.CreateChildControls(); myList = new DropDownList(); myList.AutoPostBack = true; this.Controls.Add(myList); if (!Page.IsPostBack) {...

Noob DetailView/FilterExpression Question (C#, Visual Studio 2010)

I have a DetailView (RunnerDetails) bound to RunnerDataSource, and I set the FilterExpression of that DataSource from user input: String WhereClause = FindBox.Text; RunnerDataSource.FilterExpression = WhereClause; RunnerDetails.DataBind(); The DetailView then immediately re-displays with the correct info, but w...

Binding Data From SQL Server to a Label(s)

I'm doing such a small web page that contain 4 main HTML div which should contain last 4 NEWS from a SQL Database. so I've designed them, and put in each on a label control, and an Image control. and to bind information from the SQL to them, I've used (DataView) object, and using a loop from 0 to 3 I've get the data I need. but I be...