0
我有這個WPF是通過表單重複:綁定自定義附加屬性的代碼或樣式/模板
<WrapPanel local:RadioChecker.IsChecked="False">
<RadioButton Content="Yes" Height="16" GroupName = "rbgSeizure" Name="rbSeizureYes"
local:RadioChecker.IsChecked="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" />
<RadioButton Content="No" Height="16" GroupName = "rbgSeizure" Name="rbSeizureNo"
local:RadioChecker.IsChecked="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" />
</WrapPanel>
什麼是去在同一設置每個WrapPanel如上每個單選按鈕的方式而不必將上面的local:...
複製並粘貼到每個控件上?
我可以在代碼中的每個類型的控制背後,如:
GetLogicalChildCollection<RadioButton>(mainPanel)
.ForEach(rb =>
{
Binding binding = new Binding();
//binding.Source
});
但我不知道如何設置綁定的/附加屬性附加到自定義的控件。
一種方式是從單選按鈕獲得MyRadioButtonWithCustomAttachedProperty。 –