1024programmer Asp.Net wpf RelativeSource binding

wpf RelativeSource binding

wpf RelativeSource binding

There are four types of RelativeSource

Self

FindAncestor

TemplatedParent

PreviousData

a.Self

Self is used in scenarios where the binding source and binding target are the same. A property of an object is bound to another property of the same object.

For example, let’s take an ellipse with the same height and width. Add the code given below in the XAML file. The width property is bound relatively to the height property.


     
 

b. Find Ancestor

FindAncestor
As the name implies, this option is used when the binding source is one of the ancestors (parents) of the binding target. With the FindAncestor extension, any level of ancestors can be found.

Now, let’s use the FindAncestor extension to bind the ancestor’s Name property to the Content property of the child element button.


     
         
             
                 
                     
                     

c. TemplatedParent

TemplatedParent is a property that enables you to create a control template that contains a small number of unknown values. These values ​​depend on the properties of the control to which the ControlTemplate is applied.

 
         
             
             
                 
                 
                 
             
         
     

d. PreviousData

PreviousData This is rarely used to indicate the change of the value relative to the previous data.

The final rendering

Article Navigation
  1. https://github.com/aierong/WpfDemo (self-Demo address)

My Series
A.Sql Server2005 Transact-SQL new weapon learning
B.MCAD learning
C.Code Reading Summary
D.ASP.NET State Management
E.DB (database)
F.WAP
G.WinForm

H.Flex



banner

I hope the knowledge mentioned above can give you some hints, and welcome to exchange and correct.
Author: aierong
Source: http://www.cnblogs.com/aierong
The post is based on “the status quo “Provided without any guarantee, and at the same time, no rights are granted!
The copyright of this article belongs to the author, welcome to reprint!
Original technical articles and experiences, reprint and indicate the source! This is also respect for the original creator!

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/wpf-relativesource-binding/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索