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

Repeater only goes horizontal on Grid Layout

Last post 11-23-2010, 6:22 AM by sccrgoalie1. 16 replies.
Page 1 of 2 (17 items)   1 2 Next >
Sort Posts: Previous Next
  •  11-08-2010, 5:16 AM 9978

    Repeater only goes horizontal on Grid Layout

    Hello,

    I am trying to implement a guide page using Grid Layout and a repeater. The problem is my repeater stays on one row and I need it to go to multiple rows. Ultimately this page needs to scroll both horizontally and vertically for obvious reasons with a guide page. Can someone help me figure out how to get rows going in addition to the columns I currently have. This is very basic just displaying text currently. I don't know why my markup doesn't showup (it's all in the compose window)

    xmlns:me="Me"
    xmlns:cor="assembly://MsCorLib/System">




    BeginPadding="200"
    BeginPaddingRelativeTo="Near"/>






    ScrollingData="[ScrollData]"
    Navigation="FlowHorizontal"
    FadeSize="1">



    Content="GridLayout Sample"
    Font="Arial,50">

























    RepeatPolicy="Always"/>
    Size="0,0"/>































    Value="[Mode]">





    Value="[MaximumConstraint]">













    Margins="0,25,0,0"
    Padding="10,10,10,10"
    MaximumSize="[MaximumConstraint]">

    Spacing="5,0"/>




    Font="Arial,20"
    Color="White"/>
    Font="Arial,20"
    Color="White"/>


    FadeSize="30">



    Layout="Grid"
    Navigation="Row">





    Columns="7"
    Rows="5"
    Spacing="10,10"
    MajorAlignment="Fill"
    MinorAlignment="Fill"
    AllowWrap="true"/>


    StringSource="[RepeatedItem!cor:String]"/>















    Index="$Required"/>
    cor:String="$Required"/>




    Value="true"/>
    SourceValue="true"
    Target="[Background.Content]"
    Value="Gray"/>









    Content="DarkBlue"
    Padding="5,5,5,5">

    ItemAlignment="Center"/>






    ItemAlignment="Near"/>














    Type="Move">

    Value="0,0,0"
    RelativeTo="Current"/>
    Value="0,0,0"/>



  •  11-08-2010, 6:57 AM 9981 in reply to 9978

    Re: Repeater only goes horizontal on Grid Layout

    If you want to make a guide page, your best bet is to *not* use scrollers. You won't be able to make a guide that looks like the Media Center one if you use scrollers, and you'll find yourself getting into all sorts of problems.

    If you really want to use them, make a "row" UI with the horizontal repeater in it, and use this UI in your vertical repeater rather than trying to nest repeaters.

    Cheers,
    Andrew
  •  11-08-2010, 8:57 AM 9982 in reply to 9981

    Re: Repeater only goes horizontal on Grid Layout

    I am new to this as you might guess. If I shouldn't use scrollers how do you recommend implementing a guide page that navigates up/down/left/right? It appears your suggestion above is how to use scrollers successfully. Thanks for your help as I get rolling on this!
    Mark
  •  11-09-2010, 12:04 AM 9983 in reply to 9982

    Re: Repeater only goes horizontal on Grid Layout

    One problem is that scrollers clip the contents so you won't be able to accurately focus the item with a focus rectangle (the left or right hand side will be clipped).

    Another is that when you have 14 days of guide for several hundred channels, it has the potential to get very slow - slow to load, slow to navigate.

    If you have a simple layout of 7 rows with a UI within each that just displays the current visible content using a repeater, and you trap left/right/up/down to allow you to insert and delete items from the repeater to simulate scrolling.

    Cheers,
    Andrew
  •  11-09-2010, 5:08 AM 9986 in reply to 9983

    Re: Repeater only goes horizontal on Grid Layout

    Thanks! I'll see if I can get that going! I appreciate the push in the right direction.
  •  11-09-2010, 7:03 PM 9987 in reply to 9986

    Re: Repeater only goes horizontal on Grid Layout

    For my repeater I need to specify the size of each panel independently. So, I am setting the minimum size on my panel to say 200,0. But I need to change to 200 based on the length of the program. My question is how do I pass a size down to the repeater. Trying to do something like this

    Panel MinimumSize="[RepeatedItem!cor:Int32],0"

    isn't valid mcml. How can I make my repeater item a variable size?

    Also, is it possible to add Int32 values to this list in mcml for each string. Just for ease of testing.
    ArrayListDataSet Name="List"
    Source
    cor:String String="Repeater1"
    cor:String String="Repeater2"
    cor:String String="Repeater3"
    cor:String String="Repeater4"
    Source
    ArrayListDataSet
  •  11-10-2010, 12:54 AM 9991 in reply to 9987

    Re: Repeater only goes horizontal on Grid Layout

    To act on items in a repeater you need to make your actions happen in the items themselves rather than at the repeater level.

    Create a C# class inheriting from ModelItem to store your item data in (including the Size property), and create a UI for the item that is to be displayed by the repeater. Change the Size property in the item and it will be changed in the UI, provide you have bound your UI size to the C# property.

    Cheers,
    Andrew
  •  11-11-2010, 3:23 PM 9996 in reply to 9991

    Re: Repeater only goes horizontal on Grid Layout

    Hi Andy,

    Thanks for all the help so far. I currently have all my data bound successfully. I am now trying to implement the the down key press. What I want to do is call a method in my c# code when the down key is pressed. What happens is I get a The 'App' member on Microsoft.MediaCenter.UI.View' returned "null" and evaluation could not continue. If you could give me another push that would be great. Thanks again.

    Mcml
    UI Name="RepeatedItemDown"
    Properties
    cor:String Name="Item"
    String="$Required"
    Size Name="PSize"
    Size="0,0"
    Properties
    Locals
    a:Application Name="App"
    Application="$Required"
    KeyHandler Name="DownKey" Key="Down" HandlerStage="Bubbled"
    ClickHandler Name="Clicker"
    Locals
    Rules
    Mark ourselves as KeyInteractive so we can receive key focus.
    Default Target="[Input.KeyInteractive]"
    Value="true
    Condition Source="[Input.KeyFocus]"
    SourceValue="true"
    Target="[Background.Content]"
    Value="Green"
    Condition Source="[Clicker.Clicking]"
    SourceValue="true"
    Actions
    Invoke Target="[App.downKeyPressed]"
    Actions
    Condition
    Changed Source="[DownKey.Invoked]"
    Actions
    Invoke Target="[App.downKeyPressed]"
    Actions
    Changed
    Rules
    Content
    Panel MinimumSize="[PSize]"
    Children
    ColorFill Name="Background"
    Content="MidnightBlue"
    Padding="5,5,5,5"

    Children

    Text Content="[Item]"
    Color="DarkGray"
    Margins="5,5,5,5"

    Children
    ColorFill
    Children
    Panel
    Content
    /UI

    c#
    public void downKeyPressed()
    {

    Row1 = Row2;
    Row2 = Row3;
    Row3 = Row4;
    Row5 = Row6;
    Row6 = Row7;



    }
    Brackets removed to get text to show up.
  •  11-12-2010, 12:12 AM 9997 in reply to 9996

    Re: Repeater only goes horizontal on Grid Layout

    In your MCML, you show Application="$Required" in your locals section - $Required is the equivalent of "null", so remove that and an instance of Application will be created as a local.

    Just as an aside, if you put your rows inside an ArrayListDataSet and show it using a repeater, you can remove the first row of the dataset and add a row to the end, and the screen will update automatically.

    Cheers,
    Andrew
  •  11-12-2010, 4:28 AM 9998 in reply to 9997

    Re: Repeater only goes horizontal on Grid Layout

    I removed the $Required as suggested and it's still throwing a nullreference exception.


    Exception System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at Microsoft.MediaCenter.UI.Template.FastMethodInfo.Invoke(Object obj, Object[] arArgs)
    at Microsoft.MediaCenter.UI.ObjectPath.MethodOperations.Invoke(Object instance, String stPath, Object[] arArgs)
    at Microsoft.MediaCenter.UI.Template.InvokeMethodService.MethodInvoke(IVirtualPropertyObject vpoHost, ObjectPath ipMethod, ObjectPath ipResult, Object objTransformer, Object objOwner, IList exHandlers)
    at Microsoft.MediaCenter.UI.Invoke.ApplyWorker(Object args)
    at Microsoft.MediaCenter.Queues.Dispatcher.MainLoop(Queue queue)
    at Microsoft.MediaCenter.UI.UIDispatcher.MainLoop(Queue queue, LoopCondition condition)
    at MediaCenter.Extensibility.Host.Main(String[] args)

    InnerException System.NullReferenceException: Object reference not set to an instance of an object.

    at MyProject.Application.downKeyPressed()

    Any thoughts?
  •  11-12-2010, 4:53 AM 9999 in reply to 9998

    Re: Repeater only goes horizontal on Grid Layout

    Oh and I'll be switching to an ArrrayListDataSet for the rows as you suggest. Thanks!
  •  11-12-2010, 12:41 PM 10000 in reply to 9999

    Re: Repeater only goes horizontal on Grid Layout

    I've switched to ArrayListData Set. It works great. Also, I found a solution to the above problem. Thanks to you of course. You said creating an "instance" of the application object. I want the original not an instance. I solved this by passing it down. is there a concept of "global variables" in mcml?
  •  11-12-2010, 11:42 PM 10001 in reply to 10000

    Re: Repeater only goes horizontal on Grid Layout

    You implement application global variables by creating a property on your "Application" class and pass that in to each page. Same for page globals - create them on a class that you use to provide page variables to each page.

    My approach to this is to always have a page class, which is named the same as the page - e.g. if you have DefaultPage.mcml then have DefaultPage.cs which you instantiate in your Launch method and pass in as a property to your page.

    Cheers,
    Andrew
  •  11-19-2010, 2:42 PM 10009 in reply to 10001

    Re: Repeater only goes horizontal on Grid Layout

    Hi Andy,

    I've successfully got up and down scrolling working but the side is being a little trickier. To imitate scrolling I am trying to remove or resize the first item in the grid row when the right key is pressed and add items to the end as necessary. The problem is in the resize the item does not update on the screen properly. The size doesn't change. The size I am changing is the maximum and minimum size of a panel (an individual guide listing).

    c#
    public Size PSize
    {
    get
    {
    return mSize;
    }
    set
    {
    if (mSize != value)
    {
    mSize = value;
    base.FirePropertyChanged("PSize");
    }
    }
    }

    MCML (Repeater UI portion)

    Panel MinimumSize="[PSize]"
    MaximumSize="[PSize]"
    Children
    ColorFill Name="Background"
    Content="MidnightBlue"
    Padding="5,5,5,5"

    Children

    Text Content="[Item]"
    Color="DarkGray"
    Margins="5,5,5,5"

    Children
    ColorFill
    Children


    Any thoughts on where the problem might be?
  •  11-19-2010, 3:21 PM 10010 in reply to 10009

    Re: Repeater only goes horizontal on Grid Layout

    I solved this by just removing and re-adding the item. But, if you have any pointers on what I am doing wrong let me know.
Page 1 of 2 (17 items)   1 2 Next >
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems