The Media Center Sandbox

Resources and discussion for developing experiences in the Windows Media Center platform.
Welcome to The Media Center Sandbox Sign in | Join | Help
in Search

Bind Text Label in a FlowLayout

Last post 02-24-2008, 7:43 PM by IgnoranceIsBliss. 4 replies.
Sort Posts: Previous Next
  •  02-21-2008, 5:07 AM 6696

    Bind Text Label in a FlowLayout

    Hello ppl.

    I'am starting to understand a lot more of MCML, and I have been able to
    make a layout similar to MyMusic to browse my albums given by a server.

    I'd like to know where i should put the text object to act similar to MyMusic (music title, time,etc).
    Inside the repeater or inside the repeated object? Or a different UI (bottom?)
     I think i know how to bind the text using the binding targets, my doubt is just
    where to put it and don't lose the behavior of the scroller.

  •  02-21-2008, 5:50 AM 6697 in reply to 6696

    Re: Bind Text Label in a FlowLayout

    If I understand your question right, I think you should add a panel for the text at the same level as the scroller and then place a panel around those two. The outer panel needs a form- or anchorlayout. You can make the inner panel align to the focused item in the scroller by adding a layoutinput that anchors to the focused item, like this:
    <LayoutInput>
        <FormLayoutInput Left="Focus,0" Top="Focus,0"/>
     </LayoutInput>

    Add the following animation to make the panel slide smooth:

                 <Animation Type="Move">
                    <Keyframes>
                      <PositionKeyframe Time="0" RelativeTo="Current" Interpolation="Exp"/>
                      <PositionKeyframe Time="0.2" RelativeTo="Final"/>
                    </Keyframes>
                  </Animation>
  •  02-21-2008, 7:50 AM 6701 in reply to 6697

    Re: Bind Text Label in a FlowLayout

    Hello ruthjes.

    Yes you have understanded my question. But the ways i've tried the label appears behind
    or on the rigth of the scroller...

    I have something like this...
    <Children>
                                <Graphic Name="FocusOutline" Content="image://me:FocusOutline" Visible="true" SizingPolicy="SizeToConstraint" Scale="1.26, 1.26, 1.26" CenterPointPercent="0.5,0.5,0.5">
                                    <LayoutInput>
                                        <FormLayoutInput Left="Focus,0,-4" Right="Focus,1,4" Top="Focus,0,-4" Bottom="Focus,1,4" ContributesToWidth="false" ContributesToHeight="false"/>
                                    </LayoutInput>

                                   
                                </Graphic>

                                <Scroller ScrollingData="[ScrollingData]" Orientation="Horizontal">
                                    <LayoutInput>
                                        <AnchorLayoutInput Left="Parent,0,224"/>
                                    </LayoutInput>

                                    <Children>
                                        <Repeater Name="rep" Source="[Server.Players.Options]">
                                            <Layout>
                                                <GridLayout Spacing="50,50" AllowWrap="true" Orientation="Horizontal" RepeatGap="70" Repeat="WhenTooBig"/>
                                            </Layout>

                                                                              
                                            <Content>
                                                <me:MyPlayer var="[RepeatedItem!a:Player]"/>
                                            </Content>
                                        </Repeater>
                                    </Children>
                                </Scroller>
                            </Children>

    In this example, i want to change the player name label (class Player have lots of properties) when i change the player in the scroller.
    I tried different combinations with panels with a simple test string just to find the correct location but with no success so far...

    Any sugestions?


    PS - How do i format the code with colors and that stuff?  it looks ugly like this sorry.
  •  02-21-2008, 10:01 AM 6706 in reply to 6697

    Re: Bind Text Label in a FlowLayout

    Hi again.
    Thanks for the tip.

    I make it work like this:

    <Children>

    <Scroller ScrollingData="[ScrollingData]" Orientation="Horizontal"> bla bla</Scroller>

    <Text Content="TESTING" Color="White">

       <LayoutInput>

          <FormLayoutInput Left="Focus,0,-30" Top="Focus,0,200"/>

    </LayoutInput>

    </Text>

    </Children>

    I had to use some values to get it aligned the way i want.

    Now I'll try to bind it , but i guess it will be complicated... unless i pass the property to the repeatedItem.

  •  02-24-2008, 7:43 PM 6731 in reply to 6706

    Re: Bind Text Label in a FlowLayout

    If you want it to work like Music, Videos etc, I think you want the text to be completely outside the repeater.

    You can create another UI (or just a <panel> with a few text objects) outside the repeater, and simply bind it to the values found in the 'Chosen' property of the Choice object.

     

    I'm assuming here that you have a Choice object containing all of your music, and each entry in the Choice object is actually a class that you've designed - something like this...

    class MyMusicEntry : ModelItem

    {

       public string _Artist, _Album, _Duration;

       public string Artist { get { return _Artist; } }

       public string Album { get { return _Album; } }

       public string Duration { get { return _Duration; } }

       public string Description { get { return _Artist+ " / " + _Album; } }

    }

     

    So, all you'd have to do is bind your property to something like the following...

       <Binding Target="[MyTextObject.Content]" Source="[MyObject.ChoiceObject.Chosen!a:MyMusicEntry.Description]"/>

    This way, whenever your Chosen item changes, your text should automatically update itself, with no need to fiddle with visibility or anything else.


    100 downloads a day for Yougle Vista - goin' allright!

    Check out http://www.thedigitallifestyle.com/cs/Blogs/developer/default.aspx and http://www.push-a-button.com.au/products/mce
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems