In WPF Databinding, I understand that you have DataContext which tells an element what data it is going to bind to and ItemsSource which "does the binding".
But e.g. in this simple example it doesn't seem that ItemsSource is doing anything useful since, what else would you want the Element to do to the DataContext except bind to it?
<...
I need to update all the bindings on my UserControl when its visibility changes to Visible. Pretty much all my bindings are bound to the DataContext property of the user control so I'm trying to update the target of that binding:
BindingOperations.GetBindingExpressionBase(this, UserControl.DataContextProperty).UpdateTarget();
But I ge...
Good afternoon all,
I have to work with a legacy Winforms application but I'd like to start migrating it to WPF. It doesn't have a tooltip control now so I'd like to use a WPF tooltip object.
I create a single global instance of a tooltip object. I've bound the controls within it and my application sets the datacontext of the tooltip. I...
I have a databound WPF CheckBox control that appears to be eating exceptions thrown by the corresponding property setter when the value is toggled in the UI. I know this can happen if I provide a ExceptionValidationRule on the Binding instance, but I double checked that the ValidationRules for the Binding instance has count zero. I als...
I use a ListView to show a list of errors as they occur in my application. It behaves and looks exactly like the Error List in Visual Studio. I want to add auto-scrolling when the last error item is selected (like how Visual Studio's Log Window auto-scrolls when you place the caret at the end).
The list of errors is in an ObservableColl...
I have a user control - say "ControlBase". It has "SomeItems" property, which is an ObservableCollection<InheritedFromDO>, where InheritedFromDO is a class inherited from "DependencyObject".
When I create markup for a child class of the ControlBase i'd like to initiate the "SomeItems" collection. But somehow I cannot use bindings in that...
I'd like to bind a Dictionary<string, int> to a ListView in WPF. I'd like to do this in such a way that the Values in the Dictionary get updated via the data binding mechanism. I don't want to change the Keys just the Values. I also don't care about adding new mappings to the Dictionary. I just want to update existing ones.
Setting the ...
Hi,
when I try to run DataBind() on my DataList to enhance ObjectDataSource wired to GetOfferPhotosAccPhotoTableAdapter in .xsd file I get the error: (translated)
The type
webpresence.App_Code.OfferDetailsTableAdapters
.GetOfferPhotosAccPhotoTableAdapter
has multiple meanings it can originate
from assembly C:\Users\Admin
Us...
I can bind a ListBox like this:
XAML:
<UserControl x:Class="TestDynamicForm123.Views.ViewCustomers"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Margin="10">
<ListBox ItemsSource="{Binding}"/>
</StackPanel>
</UserControl>...
I'm trying to bind my view to my view model without DataObjectProvider.
The following code runs without an error, but my ListBox is empty.
As far as I can tell, I correctly:
set the View's DataContext to the ViewModel itself (DataContext = new CustomersViewModel();)
expose the customer objects in the ViewModel (public static Observab...
Hi,
I have a column of a DataTable bound to a Label (via a BindingSource).
If I make a change to the current row thus
row["Column Name"] = "New Value";
the change is not reflected in the bound label unless I also do
bindingSource.ResetCurrentItem();
However, if I wrap the change to the column in a Begin/EndEdit as follows
row.Be...
I'm trying to access datasource before I bind it to grid. How do I do that? My guess I should look in one of the events like Grid.DataBinding
...
I've been playing around with assigning an ASP.NET WebControl's DataSource when I'm handling its DataBinding event. For general data binding logic in my pages, it seems to work well in organizing things.
What arguments are there for not doing this?
...
On my journey to learning MVVM I've established some basic understanding of WPF and the ViewModel pattern. I'm using the following abstraction when providing a list and am interested in a single selected item.
public ObservableCollection<OrderViewModel> Orders { get; private set; }
public ICollectionView OrdersView
{
get
{
...
We have an object that derives from DependencyObject, and implements some DependencyProperties.
Basically something like this:
class Context : DependencyObject {
public static readonly DependencyProperty NameProperty =
DependencyProperty.Register ("Name", typeof (string), typeof (Context), new PropertyMetadata (""));
public s...
I created an attached property, AttachedBehaviorsManager.Behaviors that is to be used as an MVVM helper class that ties events to commands. The property is of type BehaviorCollection (a wrapper for ObservableCollection). My issue is that the Binding for the Behavior's Command always winds up being null. When used on the buttons it works ...
I'm getting the following message when I try to remove the last item in a datagridview.
DataBinding cannot find a row in the list that is suitable for all bindings.
I have my binding setup as follows.
ExtendedBindingList<MyClass> bl = new ExtendedBindingList<MyClass>(GetDataFromDB());
BindingSource bs = new BindingSource();
bs.Dat...
I have the following XAML for a databound items control to show a list of groups, with a label and button to add a new group appearing first:
<WrapPanel Orientation="Horizontal">
<Label Content="Groups" />
<Button x:Name="btnGroupAdd" Click="btnGroupAdd_Click" Content="+" />
<ItemsControl ItemsSource="{Binding}" x:Name="_groupList" >...
I have a TextBox bound to a ViewModel's Text property with the following setup:
Xaml
<TextBox Text="{Binding Text}"/>
C#
public class ViewModel : INotifyPropertyChanged
{
public string Text
{
get
{
return m_Text;
}
set
{
if (String.Equals(m_Text, value))
...
I would like to pass a parameter defined in the XAML (View) of my application to the ViewModel class by using the RelayCommand. I followed Josh Smith's excellent article on MVVM and have implemented the following.
XAML Code
<Button
Command="{Binding Path=ACommandWithAParameter}"
CommandParameter="Orange"
...