http://msdn.microsoft.com/en-us/library/ms742863.aspx
public class MyData : INotifyPropertyChanged
{
private string myDataProperty;
public MyData() { }
public MyData(DateTime dateTime)
{
myDataProperty = "Last bound time was " + dateTime.ToLongTimeString();
}
public String MyDataProperty
{
get { return myDataProperty; }
set
{
myDataProperty = value;
OnPropertyChanged("MyDataProperty");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string info)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(info));
}
}
}
//make a new source
MyData myDataObject = new MyData(DateTime.Now);
Binding myBinding = new Binding("MyDataProperty");
myBinding.Source = myDataObject;
myText.SetBinding(TextBlock.TextProperty, myBinding);
分享到:
相关推荐
Create and debug C# applications in Visual Studio 2013 Work with variables, identifiers, statements, operators, and methods Create interfaces and define abstract classes Write robust code that can ...
Using this book, you’ll learn how to implement world-class WPF solutions in a real-world line of business applications, developing the code from the ground up, and understand how to apply best ...
example that shows how to create and manage dynamic animations with code. Chapter 17: Control Templates shows you how you can give any WPF control a dramatic new look (and new behavior) by plugging ...
With Getting to Know Vue.js, you’ll see how to combine reusable code with custom components, allowing you to create snippets of reusable code to suit your specific business needs. You’ll also ...
In Pro JavaFX 2: A Definitive Guide to Rich Clients with Java Technology, Jim Weaver, Weiqi Gao, Stephen Chin, Dean Iverson, and Johan Vos show you how you can use the JavaFX platform to create rich-...
With Getting to Know Vue.js, you’ll see how to combine reusable code with custom components, allowing you to create snippets of reusable code to suit your specific business needs. You’ll also ...
The final section in this chapter shows us how to create highly optimized URLs for our user profiles, and how to build custom Route classes to obtain even more flexibility. Chapter 7, Creating and ...
Item 43: Use Expressions to Transform Late Binding into Early Binding 261 Item 44: Minimize Dynamic Objects in Public APIs 267 Chapter 6 Miscellaneous 275 Item 45: Minimize Boxing and Unboxing 275 ...
Written by a MySQL Community Manager for Oracle, MySQL and JSON: A Practical Programming Guide shows how to quickly get started using JSON with MySQL and clearly explains the latest tools and ...
This team of authors takes you on a journey through all of the new development features of the Windows 8 platform specifically how to utilize Visual Studio 2012 and the XAML/C# languages to produce ...
* Covers everything you need to know about Extensible Application Markup Language (XAML) * Examines the WPF feature areas in incredible depth: controls, layout, resources, data binding, styling, ...
Starting with coverage of C++/CX (a set of extensions that make working with WinRT easier) and user interface design with XAML, this book shows you how to use major Windows 8 features, including Live ...
Using the Palette to Create a Window 227 Putting Widgets into the Window 228 Glade Creates an XML Representation of the GUI 230 Try It Out: Building a GUI from a Glade File 231 Creating a Real ...
to easily create and maintain literally hundreds of thousands of lines of code, so much of the credit for the vastness of wxPython’s feature set deserves to go to David Beazley and the other ...
From organizing your code in a logical and physical way, you will go on to delimit view responsibilities and work with complex layouts. Synchronizing models in a two-way binding can be difficult and...
From organizing your code in a logical and physical way, you will go on to delimit view responsibilities and work with complex layouts. Synchronizing models in a two-way binding can be difficult and...
Finally, we take an in-depth look at Vuex for state management and Vue Router to route in your single page applications, and integrate a variety of technologies ranging from Node.js to Electron, and ...