AbsoluteLayout.LayoutBounds from a ResourceDictionary?

jfritsch_crsjfritsch_crs ✭✭USUniversity ✭✭

Are the AbsoluteLayout.LayoutBounds of a control able to be set through a ResourceDictionary object, specifically using OnIdiom with it as well? Whenever I try it, my controls just seem to disappear. But if I set the same LayoutBounds directly onto the control, it works just fine.

AbsoluteLayout.LayoutFlags does not seem to have this issue.

This works:

<ResourceDictionary>
  <AbsoluteLayoutFlags
    x:Key="ContainerAbsoluteLayoutFlags">
    All
  </AbsoluteLayoutFlags>
</ResourceDictionary>

<AbsoluteLayout>
  <ContentView
    VerticalOptions="FillAndExpand"
    HorizontalOptions="FillAndExpand"
    AbsoluteLayout.LayoutFlags="{StaticResource ContainerAbsoluteLayoutFlags}">
    <AbsoluteLayout.LayoutBounds>
      <OnIdiom
        x:TypeArguments="Rectangle"
        Phone="0.5, 0.5, 1, 1"
        Tablet="0.5, 0.5, 0.8, 1" />
    </AbsoluteLayout.LayoutBounds>
    <StackLayout
      VerticalOptions="Center"
      HorizontalOptions="Center">
      <Label
        Text="My Label" />
      <Button
        Text="My Button" />
    </StackLayout>
  </ContentView>
</AbsoluteLayout>

This does not work:

<ResourceDictionary>
  <AbsoluteLayoutFlags
    x:Key="ContainerAbsoluteLayoutFlags">
    SizeProportional
  </AbsoluteLayoutFlags>
  <Rectangle
    x:Key="ContainerAbsoluteLayoutBounds">
    <OnIdiom
      x:TypeArguments="Rectangle"
      Phone="0.5, 0.5, 1, 1"
      Tablet="0.5, 0.5, 0.8, 1" />
  </Rectangle>
</ResourceDictionary>

<AbsoluteLayout>
  <ContentView
    VerticalOptions="FillAndExpand"
    HorizontalOptions="FillAndExpand"
    AbsoluteLayout.LayoutFlags="{StaticResource ContainerAbsoluteLayoutFlags}"
    AbsoluteLayout.LayoutBounds="{StaticResource ContainerAbsoluteLayoutBounds}">
    <StackLayout
      VerticalOptions="Center"
      HorizontalOptions="Center">
      <Label
        Text="My Label" />
      <Button
        Text="My Button" />
    </StackLayout>
  </ContentView>
</AbsoluteLayout>

Interestingly, if I don't use OnIdiom, the ResourceDictionary object does work. The problem is I need OnIdiom to work.

<ResourceDictionary>
  <Rectangle
    x:Key="ContainerAbsoluteLayoutBounds">
    0.5, 0.5, 0.8, 1
  </Rectangle>
</ResourceDictionary>

Answers

  • jfritsch_crsjfritsch_crs ✭✭ USUniversity ✭✭

    Bug report 55183 has been created.

    Note that AbsoluteLayout.LayoutFlags does actually have this issue as well. I didn't test that well enough the first time around.

Sign In or Register to comment.