我已經單選按鈕,我想定義radiobutton.IsChecked狀態和一些StackPanel的,所以我寫了這個轉換方法的可見性之間的綁定:我的綁定轉換有什麼問題?
public class RadioBtnState2Visible : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (bool)value == true ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (Visibility)value == Visibility.Visible ? true : false;
}
}
我做結合 - 的XAML:
<local:PageEx.Resources>
<local:RadioBtnState2Visible x:Key="Convert" />
</local:PageEx.Resources>
<RadioButton x:Name="MyRadioBtn1" GroupName="group1" />
<RadioButton x:Name="MyRadioBtn2" GroupName="group1" />
<StackPanel Visibility="{Binding ElementName=MyRadioBtn1, Path=IsChecked, Converter={StaticResource Convert}}" />
但沒有任何作品!
堆疊面板的可見性狀態始終可見!
我做錯了什麼?
輸出窗口不幫你?你有沒有試過調試它?轉換器中的斷點? – Snowbear 2011-06-15 13:30:57
我在轉換中添加了斷點 - 它並沒有在那裏停止。 – Yanshof 2011-06-15 13:43:31
這意味着轉換器不會被解僱 – Rohit 2011-06-15 14:26:24