Uploaded image for project: 'MediaPortal 2'
  1. MediaPortal 2
  2. MP2-932

Elements added as a child of a ContentControl are not registered in the correct namescope

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 2.5
    • Skin Engine
    • None

    Description

      Elements added as children of a ContentControl, e.g. Button, in xaml are not registered in the correct namescope if the ContentControl's ContentPresenter is contained in a Template.
      The child elements get registered in the ContentControl's namescope but end up being displayed as children of the ContentPresenter, which has it's own namescope if it is contained in a template. Any references to named elements in the content, e.g. binding to an element name, end up looking in the ContentPresenter's namescope and not the ContentControl's namescope and therefore do not find the elements.

      Example of broken behaviour:

      <Button>
          <Button.Template>
              <ControlTemplate>
                  <ContentPresenter />
              </ControlTemplate>
          </Button.Template>
          <Label x:Name="NamedLabel" />
          <!--
      This binding will not work because NamedLabel is registered in the same namescope as the Button,
      but ends up being displayed as a child of the ContentPresenter above which has a separate namescope because
      it is contained in it's own template. Any bindings will look in the ContentPresenter's namescope and not the
      button's namescope.
          -->
          <Label IsVisible="{Binding ElementName=NamedLabel, Path=IsVisible}" />
      </Button>

      Attachments

        Activity

          People

            Unassigned Unassigned
            brownard Brownard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: