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

[Solved] Way to hide compass in case of manual cancel?

1 Answer 97 Views
Docking
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jamest
Top achievements
Rank 2
Jamest asked on 19 Feb 2010, 12:02 AM
I have an htmlplaceholder in my document pane. I hide it when a pane from another group starts floating. I set a timer and check position of the dragging/floating pane. If the position of the floating pane hasn't changed in x seconds I readd the pane to its initial pane group. This allows me to prevent floating panes (which will become obscured by the htmlplaceholder). This is all fine except that if I do redock for the user the compass is still showing. Is there a way I can close/hide/access the compass after its been displayed or another refresh trick? Thanks in advance,
           Jordan

1 Answer, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 19 Feb 2010, 11:40 AM
Hi Jordan,

 My suggestion is to create an attached property of bool type and to set it in the CompassStyle, RootCompassStyle and VisualCueStyle. When set to true this property might collect its target object into a collection. When you need to hide all the compasses you might refer to this collection and hide all its elements. Here is an example:

The helper class with the attached property:

public class Helper
{
    private static List<UIElement> dockElements = new List<UIElement>();
 
    public static IEnumerable<UIElement> DockElements { get { return dockElements; } }
 
    public static bool GetIsDockingCompass(DependencyObject obj)
    {
        return (bool)obj.GetValue(IsDockingCompassProperty);
    }
 
    public static void SetIsDockingCompass(DependencyObject obj, bool value)
    {
        obj.SetValue(IsDockingCompassProperty, value);
    }
 
    // Using a DependencyProperty as the backing store for IsDockingCompass.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty IsDockingCompassProperty =
        DependencyProperty.RegisterAttached("IsDockingCompass", typeof(bool), typeof(Helper), new PropertyMetadata(OnIsDockingCompassChanged));
 
    private static void OnIsDockingCompassChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var element = d as UIElement;
        if (element != null)
        {
            if ((bool)(e.NewValue))
            {
                dockElements.Add(element);
            }
            else
            {
                dockElements.Remove(element);
            }
        }
    }
}
The XAML of the Docking control:

<telerikDocking:RadDocking x:Name="docking" PaneStateChange="RadDocking_PaneStateChange">
    <telerikDocking:RadDocking.CompassStyle>
        <Style TargetType="dock:Compass">
            <Setter Property="local:Helper.IsDockingCompass" Value="True" />
        </Style>
    </telerikDocking:RadDocking.CompassStyle>
 
    <telerikDocking:RadDocking.RootCompassStyle>
        <Style TargetType="dock:RootCompass">
            <Setter Property="local:Helper.IsDockingCompass" Value="True" />
        </Style>
    </telerikDocking:RadDocking.RootCompassStyle>
 
    <telerikDocking:RadDocking.VisualCueStyle>
        <Style TargetType="dock:VisualCue">
            <Setter Property="local:Helper.IsDockingCompass" Value="True" />
        </Style>
    </telerikDocking:RadDocking.VisualCueStyle>
    <telerikDocking:RadSplitContainer>
        <telerikDocking:RadPaneGroup x:Name="mainGroup">
            <telerikDocking:RadPane Header="asdf">
                <Button />
            </telerikDocking:RadPane>
            <telerikDocking:RadPane Header="asdf">
                <Button />
            </telerikDocking:RadPane>
            <telerikDocking:RadPane Header="asdf">
                <Button />
            </telerikDocking:RadPane>
        </telerikDocking:RadPaneGroup>
    </telerikDocking:RadSplitContainer>
</telerikDocking:RadDocking>
And the code I used to try your scenario - if I understood correctly you have better implementation for this:

private void RadDocking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    var pane = e.OriginalSource as RadPane;
    if (pane.IsFloating)
    {
        var timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1.5) };
        EventHandler handler = null;
        handler = (s, a) =>
            {
                timer.Stop();
                timer.Tick -= handler;
                if (pane.IsFloating)
                {
                    pane.RemoveFromParent();
                    mainGroup.Items.Add(pane);
 
                    foreach (var c in Helper.DockElements)
                    {
                        c.Visibility = Visibility.Collapsed;
                    }
                }
            };
        timer.Tick += handler;
        timer.Start();
    }
}

Hope this helps!

Kind regards,
Miroslav Nedyalkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Docking
Asked by
Jamest
Top achievements
Rank 2
Answers by
Miroslav Nedyalkov
Telerik team
Share this question
or