.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

Visual indication of whether binding target is 'dirty'

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :WPF
 
I would like to be able to show users whether data they can see is synchronised with the source object the control is bound to.  E. g. a text box receives an update from the data source so its background is set to white.  When the user starts typing the background is set to yellow.  When they press enter (running code to explicitly update the source) or the textbox loses focus or press escape (running code to revert to the source value), the background should revert to white.  If the source should changes while they're editing and the target updates, the background should also revert to white.  The aim of this is to make it totally clear the the user what data is committed and what is not.

First I tried to do this using an attached behaviour to handle SourceUpdated and TargetUpdated events from the textbox.  Unfortunately TargetUpdated only fired on they first time the textbox was updated and SourceUpdated never fired at all.  I assumed this might be because it was a routed event that was being handled elsewhere.  Unfortunately I wasn't able to get round this by calling TextBox.AddHandler with handleEventToo = True because SourceUpdatedEvent is not a member of TextBox.  I guess this means it's not a RoutedEvent because it belongs to a Binding object which is not


View Complete Post


More Related Resource Links

Office Unbound: Bring Your Documents To Life With Data Binding In Visual Studio Tools For Office

  

Thanks to Visual Studio 2005 Tools for the Microsoft Office System, Windows Forms controls can be bound to databases, Web services, or objects and added to a workbook or document. Find out how.

Eric Carter and Eric Lippert

MSDN Magazine March 2006


Advanced Basics: Data Binding in Visual Basic .NET

  

Ken Spencer introduces data binding in Visual Basic .NET.

Ken Spencer

MSDN Magazine August 2003


WPF Binding Not Showing in Visual Designer

  
I wrote a demo app (download src here) that doesn't properly display sample data in the Visual Studio Designer and I need help. After 6+ years developing in C# and WinForms, I've decided to use WPF in my current project. I've written a small demo application to teach myself and experiment with WPF. The app simply downloads and displays recent news stories from the Google News RSS feed (see Figure below):   My first attempt at this resulted in the class called "GoogleNewsWidget." After reading about the MVVM model, however, I tried again and built "GoogleNewsWidget2" that attempts to utilize a more MVVM-oriented architecture. I'm not sure which implementation is best as they both seem to be working fine on the whole (and though I'd appreciate comments on which implementation is better, this is not my primary question). My main problem is that neither GoogleNewsWidget or GoogleNewsWidget2 play very well with the Visual Studio Designer. The GoogleNewsWidget2 loads and displays data fine when its xaml is opened directly but does not display correctly when embedded into another xaml file. The GoogleNewsWidget does not display data in the Designer in either case (see Visual Designer screenshots here). What's worse, I can't figure out a way to debug stuff in Visual Designer--are there tools for this? Any help would be appreciated

DataTrigger - Binding Value Property to Target Controls Content Property

  
This Gives me an error..   <Style x:Key="radioButtonSelctionKey" TargetType="{x:Type RadioButton}">       <Style.Triggers>       <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}},Path=ValueText}" Value="{Binding Path=Content}">       <Setter Property="IsChecked" Value="True"></Setter>       </DataTrigger>       </Style.Triggers>       </Style> Is it valid to bind Value Property. If not then does it mean that the Value propety must always fix and can not be changed or Bound to any property Dose it mean that both of the way of setting Value proeprt are WRONG..? 1) Value="{Binding Path=Content}"> Or 2) Value="{Binding RelativeSource={RelativeSource Mode=Self},Path=Content}">

Setting the target of a command binding

  

Hi,

 

I have a wpf rich text box that I open and show in a win32 application.

I declare the rtf box in a resource dictionary like so:

 

 <RichTextBox 
  x:Key="rtfBox"
  HorizontalScrollBarVisibility="Auto" 
  VerticalScrollBarVisibility="Auto" 
  HorizontalAlignment="Stretch"
  VerticalAlignment="Stretch"
 </RichTextBox>

 

 

In another place, I have a wpf window which I use as a floating tool bar. I declare it in its own xaml, similar to the following:

 

<Window x:Class="BidiFix.SandBox.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml

how to set polygon points indexed member as binding target

  

i have defined MyThumb as custom class inheriting from Thumb

MyThumb.XProperty is defined as a dependency property

I would like to do the following in its loaded event


  MyThumb thumb = sender as MyThumb;

  Binding b = new Binding();
  b.Source = thumb;
  b.Path = new PropertyPath("XProperty");
  BindingOperations.SetBinding(polygon1.Points[0], thumb.XProperty, b);

is this possible?


thank you


Is it a bug in Visual Studio 2008 in WPF Designer when binding to enum defined inside of class?

  

Hello,

 

I have following problem:

when defining an enumeration inside of class (either static class or not) I can bind to this enum, however the WPF Designer inside Visual Studio does not display designed GUI anymore and show an error Type "MyClass+MyEnum" was not found.

However I can compile and execute the code and in the combobox all enum- values are listed.

 

Code behind:

    public class MyClass
    {
        public enum MyEnum { enumValue01, enumValue02, enumValue03, enumValue04, enumValue05 }
    }

 

My xaml-code:

<Window x:Class="SampleBindingOfNestedEnumToComboBox.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"          
    xmlns:local="clr-namespace:SampleBindingOfNestedEnumToComboBox"
    Title="Window1" Height="300" Width="300">

    <Window.Resources>

Is it a bug in Visual Studio 2008 in WPF Designer when binding to enum defined inside of class?

  

Hello,

 

I have following problem:

when defining an enumeration inside of class (either static class or not) I can bind to this enum, however the WPF Designer inside Visual Studio does not display designed GUI anymore and show an error Type "MyClass+MyEnum" was not found.

However I can compile and execute the code and in the combobox all enum- values are listed.

 

Code behind:

  public class MyClass
  {
    public enum MyEnum { enumValue01, enumValue02, enumValue03, enumValue04, enumValue05 }
  }

 

My xaml-code:

<Window x:Class="SampleBindingOfNestedEnumToComboBox.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:sys="clr-namespace:System;assembly=mscorlib"     
  xmlns:local="clr-namespace:SampleBindingOfNestedEnumToComboBox"
  Title="Window1" Height="300" Width="300">

  <Window.Resources>
    <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="odp">
      <ObjectDataProvider.MethodParameters>
        <x:Type TypeName="local:MyClass+MyEnum"/>
      <

Validation when adding a new item and no target to source binding has yet taken place

  

Using: WPF (.NET 4) with Entity Framework on a SQLCE database.

In my app, the user can edit existing employees and create new employees. The same UI control is used to add and edit. In the case of editing an Employee, the DataContext for the control is the Employee object of my Entity Framework context. It is updated through binding, and the SaveChanges method is called on my EF to update the database. In the case of adding and Employee, the DataContext is a new Employee object, which will gets added to the EF and then saved. Simple.

I've been trying to hook-up validation to the control. I'm using WPF's ValidationRule objects for each field binding as required. When the field loses focus (as is the default action for a target to source binding), the validation rules are checked, which can incur an error. I can then check for the presence of these errors before allowing the employee to be saved.

But when adding a new Employee, if I go ahead and push the Save button without doing anything else, no validation takes place, becasue the bindings have never attempted to update the source! It just throws an exception as expected.

What can I do? I have ideas which would probably work, but I thought I should post here first in case I am missing something obvious! Is there a standard way to deal with t

Binding WPF Controls to an Entity Data Model

  
In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Visual Case Tool - UML Tutorial

  
The Class Diagram

The class diagram is core to object-oriented design. It describes the types of objects in the system and the static relationships between them.

Binding the multiple drop down boxes in GridView using JQuery in ASP.NET

  
Here is the code for binding the multiple drop down boxes in GridView using JQuery in ASP.NET

ASP.NET 4 and Visual Studio 2010 Web Development Beta 2 Overview

  
Many exciting changes for ASP.NET are coming in the .NET Framework version 4. This document gives an overview of many of the new features that are included in the Beta 2 release of the .NET Framework 4 and of Visual Studio 2010.

ASP.NET 4.0: WebForm Routing (quick n dirty version)

  
One of the things we're adding in ASP.NET 4.0 is built-in support for using Routing together with WebForms. Now, I'm totally aware that this is possible to do already and that a number of people have posted ways of doing this with the Web Routing feature which shipped with ASP.NET 3.5 SP1. We're just adding some features to make it easier to do

Visual Studio 2010 Beta 2

  
This is a big deal. This isn't ".NET 3.6" - there are a lot of improvements of .NET 4, and it's not just "pile on a bunch of features so you get overwhelmed." I've been working with and talking to many of the teams involved and even though it's a cheesy thing to say, this is a really customer-focused release.

ASP 4 - Whirlwind Tour around .NET 4 (and Visual Studio 2010) Beta 1

  
There's a lot of stuff that's new and added in .NET 4, but not in that "overwhelming-I-need-to-relearn-everything" way. More in that, "oh, this is way easier/simpler now" way. Like, moving data around with ADO.NET DataServices is easy, binding with client templates is easy, there's F# if you need it, the "dynamic" keyword if you need it, Silverlight's already installed, oh, and the parallel stuff will freak you out, but in a good way.

Short Overview of SharePoint Features in Visual Studio 2010

  
As you probably know, Visual Studio 2010 was announced earlier this week and it contains a lot of cool features and project templates for SharePoint developers. Below is a short overview for some of the SharePoint development related features and project templates.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend