示例#1
0
    private DependencyObject GetTopMostParent(RadioTextblock radioTextblock)
    {
        DependencyObject current = radioTextblock;

        while (current != null)
        {
            var cParent = VisualTreeHelper.GetParent(current);
            if (cParent == null || cParent == current)
            {
                break;
            }
            current = cParent;
        }
        return(current);
    }
示例#2
0
    private void RestoreOtherBackgrounds(RadioTextblock radioTextblock)
    {
        var topParent         = GetTopMostParent(radioTextblock);
        var controlsWithGroup = GetChildrenRecursive <RadioTextblock>(topParent).ToLookup(d => (string)d.GetValue(GroupProperty));
        var similar           = controlsWithGroup[radioTextblock.Group];

        foreach (var match in similar)
        {
            if (match == radioTextblock)
            {
                match.Background = ActiveColor;
            }
            else
            {
                match.Background = match.RestorationColor;
            }
        }
    }