Skip to main content
A newer version of this page is available. .
Bar

BarNameScope.IsScopeOwner Attached Property

Gets or sets whether the current element defines a new (child) name scope. This is an attached property.

Namespace: DevExpress.Xpf.Bars

Assembly: DevExpress.Xpf.Core.v18.2.dll

Declaration

Returns

Type Description
Boolean

true, if the current element defines a new name scope; otherwise, false.

Remarks

Each bar object belongs to an implicitly or explicitly created name scope.

Implicit name scopes are created in the following cases:

You can set the IsScopeOwner attached property to true to explicitly define a new (child) name scope for a specific object (typically, for a container). If no name scope is implicitly or explicitly defined for an element, the element inherits the parent’s name scope.

Thus, elements of the logical tree belong to either explicit or implicit name scopes. Name scopes form a hierarchy according to the logical tree.

Name scopes serve several purposes. The most common are listed below:

  • During merging, a container’s elements are merged to elements/containers defined in parent name scopes. Thus, bar objects defined in the same name scope or sibling name scopes are never merged. For more information, see MergingProperties.ElementMergingBehavior property.
  • When creating a Bar Item Link (BarItemLink descendant), you specify the Bar Item to which the link will refer (using the BarItem.BarItemName property). Bar item links can only refer to bar items that belong to the same name scope or the parent name scopes.
  • When creating a Bar object, you can place it in a specific Bar Container (BarContainerControl) by linking to this Container with the BarDockInfo.ContainerName property. Bars can only be linked to Bar Containers in the same name scope or child name scopes.

Example

The following example creates three MainMenuControls. The second MainMenuControl contains a link to the itemPaste item. This item is defined in a separate name scope, as the owner MainMenuControl has the BarNameScope.IsScopeOwner property set to true. Thus, the target item cannot be found, and no link referring to this item is created in the second MainMenuControl.

<StackPanel>
    <dxb:MainMenuControl>
        <dxb:BarButtonItem x:Name="itemCut" Content="Cut"/>
    </dxb:MainMenuControl>

    <dxb:MainMenuControl>
        <dxb:BarButtonItem Content="Copy"/>
        <dxb:BarButtonItemLink BarItemName="itemCut"/>
        <!--The 'itemPaste' cannot be found as it is defined in a separate name scope -->
        <dxb:BarButtonItemLink BarItemName="itemPaste"/>
    </dxb:MainMenuControl>

    <dxb:MainMenuControl dxb:BarNameScope.IsScopeOwner="True">
        <dxb:BarButtonItem x:Name="itemPaste" Content="Paste"/>
        <dxb:BarButtonItemLink BarItemName="itemCut"/>
    </dxb:MainMenuControl>
</StackPanel>

Example

The following example demonstrates how name scopes affect linking Bars to Bar Containers (BarContainerControl objects).

In this example, two name scopes are implicitly created for the two BarManagers. Two Bar Containers are defined, each in its own name scope.

Bars are linked to Bar Containers by using container names. However, if a Bar Container is located in a parent name scope, the Bar is not able to find this container. Thus, the Bar with the “‘Copy’ goes to Container 1” command is not displayed.

<StackPanel>
    <!--A separate name scope is implicitly created for each BarManager-->
    <dxb:BarManager>
        <dxb:BarManager.Bars>
            <dxb:Bar DockInfo="{dxb:DockInfo ContainerName=container2}">
                <dxb:BarButtonItem Content="'Cut' goes to Container 2"/>
            </dxb:Bar>

            <dxb:Bar DockInfo="{dxb:DockInfo ContainerName=container1}">
                <dxb:BarButtonItem Content="'Clear' goes to Container 1"/>
            </dxb:Bar>
        </dxb:BarManager.Bars>

        <StackPanel>
            <dxb:BarContainerControl x:Name="container1">
                <dxb:Bar>
                    <dxb:BarStaticItem Content="This is Container 1"/>
                </dxb:Bar>
            </dxb:BarContainerControl>

            <!--A separate name scope is implicitly created for each BarManager-->
            <dxb:BarManager>
                <dxb:BarManager.Bars>
                    <!--The following Bar is marked to be displayed in Container 1.
                    However, the Container 1 is defined in a parent name scope and thus cannot be found.
                    Thus, this Bar will be hidden.-->
                    <dxb:Bar DockInfo="{dxb:DockInfo ContainerName=container1}">
                        <dxb:BarButtonItem Content="'Copy' goes to Container 1"/>
                    </dxb:Bar>
                    <dxb:Bar DockInfo="{dxb:DockInfo ContainerName=container2}">
                        <dxb:BarButtonItem Content="'Paste' goes to Container 2"/>
                    </dxb:Bar>
                </dxb:BarManager.Bars>

                <StackPanel>
                    <dxb:BarContainerControl x:Name="container2">
                        <dxb:Bar>
                            <dxb:BarStaticItem Content="This is Container 2"/>
                        </dxb:Bar>
                    </dxb:BarContainerControl>
                </StackPanel>
            </dxb:BarManager>
        </StackPanel>
    </dxb:BarManager>
</StackPanel>
See Also