我有一個依賴項屬性,我希望它填充一些單選按鈕的標題時,IsChecked事件爲真。我已經尋找了一種方法來實現這一點,但我迄今爲止看到的都是動畫示例。我知道我需要在該EventTrigger定義內部進行綁定,但它會是什麼樣子?RadioButtons和EventTrigger
<RadioButton Content="Header1"
Margin="4"
Foreground="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked, Converter={StaticResource BoolToVisibilityConverter}}"/>
在它的器isChecked屬性爲true,我想一個辦法來填充我先前定義依賴屬性與它的頭(頭1在這種情況下)
public string HeaderSelected
{
get { return (string)GetValue(HeaderSelectedProperty); }
set { SetValue(HeaderSelectedProperty, value); }
}
// Using a DependencyProperty as the backing store for HeaderSelected. This enables animation, styling, binding, etc...
public static readonly DependencyProperty HeaderSelectedProperty =
DependencyProperty.Register("HeaderSelected", typeof(string), typeof(HeaderTestClass), new PropertyMetadata(string.Empty));
我想我會嘗試這樣的事情:
<i:Interaction.Triggers>
<i:EventTrigger EventName="IsChecked">
<ei:ChangePropertyAction
TargetObject="{Binding}"
PropertyName="HeaderSelected"
Value="Header1" />
</i:EventTrigger >
</i:Interaction.Triggers>
你可以給你一個你想要達到的樣本嗎? – Sayka
告訴我們你的嘗試 – Muds