Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
单选按钮wpf绑定_Wpf_Radio Button_Master Detail - Fatal编程技术网

单选按钮wpf绑定

单选按钮wpf绑定,wpf,radio-button,master-detail,Wpf,Radio Button,Master Detail,我有一个主细节wpf应用程序。“主”是一个数据网格,“细节”是两个单选按钮。根据行选择,在“详细信息”部分选中单选按钮 我使用inttoboolean转换器以以下方式绑定单选按钮。 xaml: 我的实现在datagrid中的前几个选择中运行良好。突然,我的两个单选按钮都没有被选中 我不知道为什么会这样,欢迎任何建议 提前谢谢 搜索绑定多个单选按钮的问题-有足够多的投诉。基本上绑定不会收到False的值,因为它没有被传递到Dependency属性..等等 尝试使用以下类而不是常规的单选按钮绑定到I

我有一个主细节wpf应用程序。“主”是一个数据网格,“细节”是两个单选按钮。根据行选择,在“详细信息”部分选中单选按钮

我使用inttoboolean转换器以以下方式绑定单选按钮。 xaml:

我的实现在datagrid中的前几个选择中运行良好。突然,我的两个单选按钮都没有被选中

我不知道为什么会这样,欢迎任何建议


提前谢谢

搜索绑定多个单选按钮的问题-有足够多的投诉。基本上绑定不会收到False的值,因为它没有被传递到Dependency属性..等等

尝试使用以下类而不是常规的单选按钮绑定到IsCheckedExt,因为它会强制更新复选框的IsChecked值

public class RadioButtonExtended : RadioButton
{
    public static readonly DependencyProperty IsCheckedExtProperty =
        DependencyProperty.Register("IsCheckedExt", typeof(bool?), typeof(RadioButtonExtended),
                                    new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Journal | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsCheckedRealChanged));

    private static bool _isChanging;

    public RadioButtonExtended ()
    {
        Checked += RadioButtonExtendedChecked;
        Unchecked += RadioButtonExtendedUnchecked;
    }

    public bool? IsCheckedExt
    {
        get { return (bool?)GetValue(IsCheckedExtProperty); }
        set { SetValue(IsCheckedExtProperty, value); }
    }

    public static void IsCheckedRealChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        _isChanging = true;
        ((RadioButtonExtended)d).IsChecked = (bool)e.NewValue;
        _isChanging = false;
    }

    private void RadioButtonExtendedChecked(object sender, RoutedEventArgs e)
    {
        if (!_isChanging)
            IsCheckedExt = true;
    }

    private void RadioButtonExtendedUnchecked(object sender, RoutedEventArgs e)
    {
        if (!_isChanging)
            IsCheckedExt = false;
    }
}

搜索绑定多个单选按钮的问题-有足够多的投诉。基本上绑定不会收到False的值,因为它没有被传递到Dependency属性..等等

尝试使用以下类而不是常规的单选按钮绑定到IsCheckedExt,因为它会强制更新复选框的IsChecked值

public class RadioButtonExtended : RadioButton
{
    public static readonly DependencyProperty IsCheckedExtProperty =
        DependencyProperty.Register("IsCheckedExt", typeof(bool?), typeof(RadioButtonExtended),
                                    new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Journal | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsCheckedRealChanged));

    private static bool _isChanging;

    public RadioButtonExtended ()
    {
        Checked += RadioButtonExtendedChecked;
        Unchecked += RadioButtonExtendedUnchecked;
    }

    public bool? IsCheckedExt
    {
        get { return (bool?)GetValue(IsCheckedExtProperty); }
        set { SetValue(IsCheckedExtProperty, value); }
    }

    public static void IsCheckedRealChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        _isChanging = true;
        ((RadioButtonExtended)d).IsChecked = (bool)e.NewValue;
        _isChanging = false;
    }

    private void RadioButtonExtendedChecked(object sender, RoutedEventArgs e)
    {
        if (!_isChanging)
            IsCheckedExt = true;
    }

    private void RadioButtonExtendedUnchecked(object sender, RoutedEventArgs e)
    {
        if (!_isChanging)
            IsCheckedExt = false;
    }
}

我尝试了搜索方面的所有其他解决方案,这是唯一对我有效的解决方案。万分感谢。我尝试了搜索方面的所有其他解决方案,这是唯一对我有效的解决方案。非常感谢。
public class RadioButtonExtended : RadioButton
{
    public static readonly DependencyProperty IsCheckedExtProperty =
        DependencyProperty.Register("IsCheckedExt", typeof(bool?), typeof(RadioButtonExtended),
                                    new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Journal | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsCheckedRealChanged));

    private static bool _isChanging;

    public RadioButtonExtended ()
    {
        Checked += RadioButtonExtendedChecked;
        Unchecked += RadioButtonExtendedUnchecked;
    }

    public bool? IsCheckedExt
    {
        get { return (bool?)GetValue(IsCheckedExtProperty); }
        set { SetValue(IsCheckedExtProperty, value); }
    }

    public static void IsCheckedRealChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        _isChanging = true;
        ((RadioButtonExtended)d).IsChecked = (bool)e.NewValue;
        _isChanging = false;
    }

    private void RadioButtonExtendedChecked(object sender, RoutedEventArgs e)
    {
        if (!_isChanging)
            IsCheckedExt = true;
    }

    private void RadioButtonExtendedUnchecked(object sender, RoutedEventArgs e)
    {
        if (!_isChanging)
            IsCheckedExt = false;
    }
}