<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<UIX 
  xmlns="http://schemas.microsoft.com/2007/uix"
  xmlns:iris="assembly://UIX/Microsoft.Iris" 
  xmlns:anim="res://ZuneShellResources!Animations.uix"
  xmlns:style="res://ZuneShellResources!Style.uix"
  xmlns:core="res://ZuneShellResources!CoreControls.uix" 
  xmlns:me="Me">

  
  
  
  <UI Name="Default">
    <Content>
      <Panel Layout="VerticalFlow">
        <Children>

          <me:FilterList>
            <Filters>
              <iris:Choice Description="Numbers">
                <Options>
                  <String String="One"/>
                  <String String="Two"/>
                  <String String="Three"/>
                </Options>
              </iris:Choice>
            </Filters>
          </me:FilterList>

          <me:FilterList>
            <Filters>
              <iris:Choice Description="Letters">
                <Options>
                  <iris:Command Description="A"/>
                  <iris:Command Description="B"/>
                  <iris:Command Description="C"/>
                </Options>
              </iris:Choice>
            </Filters>
          </me:FilterList>

        </Children>
      </Panel>
    </Content>
  </UI>
  
  
  
  
  <Class Name="FilterLabelProvider" Base="core:ModelButtonProvider">
    <Scripts>
      <Script>
        
        
        if ([Model] != null)
        {
          if (Model is iris:ModelItem)
          {
            PrimaryLabel = [((iris:ModelItem)Model).Description];
          }
          else
          {
            PrimaryLabel = Model.ToString();
          }
        }
      </Script>
    </Scripts>
  </Class>

  
  
  
  
  <UI Name="FilterList">
    <Properties>
      <iris:Choice Name="Filters" Choice="{null}"/>
      <Type Name="FilterLabelProvider" Type="{typeof(me:FilterLabelProvider)}"/>

      <ItemAlignment Name="ItemAlignment" ItemAlignment="Near"/>

      <style:Style Name="Style" Style="{null}"/>
      <style:Style Name="SelectedStyle" Style="{Style}"/>
      
      <Int32 Name="Spacing" Int32="12"/>
      <Orientation Name="Orientation" Orientation="Horizontal"/>

      
      <Boolean Name="Animate" Boolean="true"/>
    </Properties>

    <Locals>
      <Accessible Name="Accessible"/>

      <iris:BooleanChoice Name="ShouldAnimate" Value="{Animate}"/>
      <SwitchAnimation Name="PivotSlide" Expression="{ShouldAnimate}">
        <Options>
          <TransformByAttributeAnimation Name="True" Attribute="Index" Delay="0.125">
            <Source>
              <Animation Animation="{anim:Animations.PivotShowAnim}"/>
            </Source>
          </TransformByAttributeAnimation>
        </Options>
      </SwitchAnimation>
    </Locals>

    <Scripts>
      <Script>
        if (Filters != null)
        {
          Repeater.Source = [Filters.Options];
        }
      </Script>

      <Script>
        if ([Accessible.Enabled])
        {
          Accessible.Role = AccessibleRole.List;
        }
      </Script>
    </Scripts>

    <Content>
      <Repeater Name="Repeater">
        <Layout>
          <FlowLayout Orientation="{Orientation}" ItemAlignment="{ItemAlignment}">
            <Spacing>
              <MajorMinor Major="{Spacing}" Minor="0"/>
            </Spacing>
          </FlowLayout>
        </Layout>
        <Content>

          <me:FilterButton Option="{RepeatedItem}" Choice="{Filters}" Style="{Style}" SelectedStyle="{SelectedStyle}">
            <Provider>
              <core:ModelButtonProvider ModelButtonProvider="{FilterLabelProvider}" Model="{RepeatedItem}"/>
            </Provider>
            <Animations>
              <SwitchAnimation SwitchAnimation="{PivotSlide}" />
            </Animations>
          </me:FilterButton>

        </Content>
      </Repeater>
    </Content>
  </UI>

  
  
  
  
  <UI Name="FilterButton">
    <Properties>
      <Object Name="Option" Object="$Required"/>
      <iris:Choice Name="Choice" Choice="$Required"/>
      <core:ModelButtonProvider Name="Provider" ModelButtonProvider="$Required"/>

      <style:Style Name="Style" Style="{null}"/>
      <style:Style Name="SelectedStyle" Style="{Style}"/>
    </Properties>

    <Locals>
      <iris:Command Name="SelectOption"/>
    </Locals>

    <Scripts>
      
      <Script>
        [DeclareTrigger(SelectOption.Invoked)]
        Choice.Chosen = Option;
      </Script>

      
      <Script>
        bool iAmTheChosenOne = ([Choice.Chosen] == Option);
        SelectOption.Selected = iAmTheChosenOne;
        if (iAmTheChosenOne)
        {
          Button.OverrideStyle = [SelectedStyle];
        }
        else
        {
          Button.OverrideStyle = [Style];
        }
      </Script>

      <Script>
        if (Provider != null)
        {
          SelectOption.Description = [Provider.PrimaryLabel];
        }
      </Script>
    </Scripts>

    <Content>
      <core:Button Name="Button" Model="{SelectOption}" OverrideStyle="{Style}" Navigation="TabGroup"/>
    </Content>
  </UI>

</UIX>
