This is a migrated thread and some comments may be shown as answers.

Contextual Tab Binding to IsActive

1 Answer 115 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
Erich
Top achievements
Rank 1
Erich asked on 29 Aug 2013, 03:38 PM
I am trying to bind a contextual group to the IsActive property using a custom property of a UserControl. The contextual tab should only be shown after the user has selected a port from a dropdown list. I have tried each of the following with no success, but hopefully it gives you an idea of what I'm trying to do.

<telerik:RadRibbonView.ContextualGroups>
<telerik:RadRibbonContextualGroup x:Name=
"xCOM" IsActive="{Binding RelativeSource={RelativeSource Self}, Path=IsPortSelected}"/>
<telerik:RadRibbonContextualGroup x:Name=
"xCOM" IsActive="{Binding ElementName=_this, Path=IsPortSelected}"/>
<telerik:RadRibbonContextualGroup x:Name=
"xCOM" IsActive="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MyRibbon}}, Path=IsPortSelected}"/>
<telerik:RadRibbonContextualGroup x:Name=
"xCOM" IsActive="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=IsPortSelected}"/>
</telerik:RadRibbonView.ContextualGroups>

Where IsPortSelected is the property in MyRibbon:

string _port = "";
public string Port
{
    get { return _port; }
    set
    {
        if (_port == value)
        {
            return;
        }
        _port = value;
    }
}
 
public bool IsPortSelected
{
    get
    {
        if (String.IsNullOrEmpty(_port))
        {
            return false;
        } else if (_port.Equals("Port")) {
            return false;
        }
        return true;
    }
    set { }
}

Is there something wrong with my binding statement? Or do I need to do something else in the code behind, such as implementing a PropertyChangedEventHandler (which I have tried with no success as well)?

1 Answer, 1 is accepted

Sort by
0
Accepted
Pavel R. Pavlov
Telerik team
answered on 03 Sep 2013, 07:17 AM
Hi Erich,

You are on the right way to achieve your requirement. However, I think that you need to try to bind to your custom property like this:

<telerik:RadRibbonContextualGroup x:Name="CG" IsActive="{Binding RelativeSource={RelativeSource AncestorType=local:MyRibbon}, Path=IsPortSelected}" />
I achieved your requirement in the attached project. Please take a look at it and let me know if you need any further assistance.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
RibbonView and RibbonWindow
Asked by
Erich
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or