1
假設我有以下幾點:如何獲得一個控件模板內的目標的屬性值
<ControlTemplate x:Key="MyButtonTemplate" TargetType="{x:Type Button}">
<Grid>
<Rectangle Width="100" Height="20" />
</Grid>
</ControlTemplate>
<Button Template="MyButtonTemplate" Width="25" />
<Button Template="MyButtonTemplate" Width="50" />
<Button Template="MyButtonTemplate" Width="75" />
什麼我需要做的控件模板有矩形是按鈕的寬度,而不是每次硬編碼100次?有沒有辦法讓我從我的控件模板中訪問我的目標類型的屬性值?
謝謝。