WPFを書いているとthisを取得したいときがくると思います。
コードを書いたほうがわかりやすいので以下に書きます。
以下のコードはTextBlockに自分自身のToolTipの値をテキスト表示しています。
<Window x:Class="LivetWPFApplication1.Views.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" Title="MainWindow" Height="350" Width="525"> <Grid> <TextBlock ToolTip="Tooltip Message." Text="{Binding RelativeSource={RelativeSource Self}, Path=ToolTip}" /> </Grid> </Window>
Bindingで指定した「RelativeSource={RelativeSource Self}」がthisの役割を果たします。
XAMLを書いて1年くらいですが、いまだにこれを使う機会が到来してないのでどういう場合に使うのかわかんないですが、 thisはどう書くんだろうと気になったので書いてみました。