1024programmer Asp.Net wpf RelativeSource binding

wpf RelativeSource binding

wpf RelativeSource binding

RelativeSource has four types

Self

FindAncestor

TemplatedParent

PreviousData

a.Self

Self is used in scenarios where the binding source and binding target are the same. One 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 relative to the height property.


     
 

b.FindAncestor

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

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 is rarely used and represents the change in value relative to previous data.

Final renderings

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

My series of articles
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 be helpful to you, and welcome exchanges and corrections
Author: aierong
Source: http://www.cnblogs.com/aierong
The post ends with “Current Situation” “Provided without any guarantee and without granting any rights!
The copyright of this article belongs to the author, welcome to reprint!
Original technical articles and experiences, please indicate the source when reprinting! This is also a respect for the original author!

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

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
首页
微信
电话
搜索