Hubsections and ContentTemplate and ContentControl

I have a simple windows store app, based on the hub template.
The main hub contains 8 very similar hubsections. So instead of copy/pasting each hubsection properties I'd like to use some kind of template.
Each hubsection is like so:
<HubSection Width="350" x:Uid="HubSection1" Header="Header1">
<DataTemplate>          
<ListBox x:Name="lbMilitary" ItemsSource="{Binding}" Grid.Column="1" Background="Red">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="12"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource PlayerNameTextBlockTemplate}" Text="{Binding PlayerName}"/>
<TextBox Text="{Binding PlayerScore1, Mode=TwoWay}"  Style="{StaticResource TbTemplate}/>
</Grid>      
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</HubSection>
So, to simplify my XAML I have written a contentcontrol, like so:
<Page.Resources>
<ResourceDictionary>
<DataTemplate x:Key="TemplateTest">
<ContentControl>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="24" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ListBox Grid.Column="0">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock FontSize="32" Text="{Binding PlayerName}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</ContentControl>
</DataTemplate>
</ResourceDictionary>
</Page.Resources>
And I am trying to use this template like so:
<HubSection x:Name="HubSecTest" Header="Test" ContentTemplate="{StaticResource TemplateTest}"> </HubSection>
If inside my control I simply insert a simple element such as a textblock, it seems to be working. But with a listbox (such as the one in the full hubsection model), nothing displays.
What am I doing wrong ?
Also, another difficulty is that in my TextBox that is bound to PlayerScore I would like to be able to choose a specific binding for each separate hubsection, like so :
<HubSection x:Name="HubSecTest" Header="Test" ContentTemplate="{StaticResource TemplateTest}">
<!-- Bind the textblock to "PlayerName" -->
<!-- Bind the TextBox to "PlayerScore1" -->
</HubSection>
<!-- Next hubsection -->
<HubSection x:Name="HubSecTest" Header="Test" ContentTemplate="{StaticResource TemplateTest}">
<!-- Bind the textblock to "PlayerName" as in the previous section BUT -->
<-- Bind the TextBox to "PlayerScore2" -->
</HubSection>
Thanks :)

Thank you very much for your answer.
I'll try to answer your question as accurately as possible (I'm still rather new to all this ...).
Both TextBlock and TextBox are included in a single ListBox in my basic design, as you can see in the first code example. Therefore, I guess my second code example is incomplete since the template should also include a TextBox in addition to the TextBlock,
like so :
<DataTemplate x:Key="TemplateTest">
<ContentControl>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="24" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ListBox Grid.Column="0">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock FontSize="32" Text="{Binding PlayerName}"/>
<TextBox Text="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</ContentControl>
</DataTemplate>
Here, I have left <TextBox Text={Binding}"/> since in each separate HubSection I would like to be able to bind this TextBox to different properties (while the TextBlock will always be bound to PlayerName).
From your answer, I understand that this is not possible and that I should use 2 ListBox in my template.
However, I do not understand how I could do so. How would it be possible in XAML ? (if not, should I do it from code behind and how ?)
For example, what could I do when defining the HubSection below ?
<HubSection x:Name="HubSecTest" Header="Test" ContentTemplate="{StaticResource TemplateTest}">
</HubSection>
Is there a code that could allow binding the TextBlock or TexBox to different properties (for the TextBlock it is easy since I can define it in the template) ?
The itemsource is indeed the same. I have created a class called Players.cs into which the properties Players.PlayerName and Players.PlayerScore<1..n> are defined.
Thank you again for your time.

Similar Messages

  • I got a new macbook pro and am having a great deal of trouble with it from the start!  But other than that, which I will get to, I have had macs since the one following Lisa and I am a diehard apple fan, yet now with the macbook pro and Lion and its

    I could not download the upgrade to the mountain lion. my updates were taking an enormous amount of time for other programs. When I finally got the indication it was waiting to be downloaded I had to shut down. It was after 2 am and I was practically unconscious already with all the trauma of trying to find the right place for the redeem of the code to open the password. It was all confusing and poorly communicated by Apple. The terrible deterioration of Apple's written communications by non-American techies who can't write for easy understanding, even by this old time tech afficianado is heart-breaking and frustrating is putting the effects mildly.  I have not yet gone back to the mac book pro to finish the job. I am too frustrated and unhappy with the new system.  Also, I found out the hard way that my time capsule saved files on the macbook Snow Leopard, which still works fine after 6 years of use, is locked in that external drive and I cannot transfer the items except one by one or by folders on that computer to a DVD or to a flash drive, to mport to this new computer. Because the systems are not the same, I can't access the files automatically. I fear I will have further problems with the mountain lion vs. lion in seeing those files. What can I do? What should I do?  I am afraid to designate an external hard drive I purchased with the new laptop for the time capsule because then it won't work with any other computer.  I read of terrible incompatibility issues and crashes and things not working right once Mountain Lion was installed and now I am terrified they will happen to me. I just wanted the computer to be as easy to use as all the other macs I have and have had and now it is more like a horribly complicated and difficult Microsoft IBM compatible PC. I hate this. Perhaps Apple wanted to appeal to new Apple users and tried to make them comfortable while disregarding the comfort of loyal Apple users?  It's a sell-out. Meanwhile, I have to get senior tech people because the kids who try to answer my questions much of the time don't interpret what i am telling them and it takes a pro.  Perhaps the kids can answer what I should do in preferenced to scroll the screen, since the scroll indicators disappear and I can't see them and have to resort to using the arrows on the keyboard, which is not the way I like to work.    Please advise me about all of these things!

    Use the trackpad to scroll, thats what it was designed for. The scroll bars automatically disappear when not being used and will appear if you scroll up or down using the trackpad.
    This is a user-to-user forum and most people will post on here if they have problems. You very rarely get people posting to say there update went smooth. The fact is the vast majority of Mountain Lion users will not be experiencing any major problems with the OS, or maybe with apps which are not compatible, but thats hardly Apple's fault if developers don't update their apps.

  • I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    What file format did you export it to?

  • PMS and Training and Event Management

    Hi Gurus,
    Our one the of the client implementing PMS and Training and Event Management.
    Could anyone suggest me what are the questions need to be asked in initial meeting with the client.
    and if anyone has configuration documents on PMS and Training and Event management please forward to me,
    my id would be [email protected]
    Regards,
    Rajesh Soma 

    The prerequisites of PMS is OM and PA is mandatory,
    PMS is just like an interaction between the manager and the employees in an enterprise, based
    On his work they are going to put some rating etc.
      In the standard system employee called as “Appraise” Manager called as an “Appraiser” and Manager’s Manager called as Higher level manager “Part Appraiser “ can be a self-peer & customer they can save & provide their Comments to  the “Appraiser”
    First you take the requirement form client side what are the process and how Appraisal system in client then you have to prepare one sheet like Preparation ,Planning,Process
    for business functions and other check below :-
    HCM, Performance Management (Flexible) 01 - SAP Documentation
    HCM, Performance Management (Predefined) 03 - SAP Documentation
    check below once :-
    Tcodes for PMS Basic Setting
    OOHAP_BASIC      Basic Appraisal Template Settings
    OOHAP_CATEGORY      Appraisal Category Settings
    OOHAP_CAT_GROUP Category Group Settings
    OOHAP_SETTINGS_PA PA: Settings
    OOHAP_VALUE_TYPE Standard Value Lists
    T codes for PMS Process
    PHAP_ADMIN     Administrator - Appraisal Document
    PHAP_CATALOG     Appraisal Template Catalog
    PHAP_CHANGE     Change Appraisal Document
    PHAP_CREATE     Create Appraisal
    PHAP_PREPARE     Prepare Appraisal Documents
    PHAP_SEARCH     Evaluate Appraisal Document
    start your work with above things any other post here again ......

  • Is there a way to create form fields to tab into and type and or drop down selection fields in pages as you can with microsoft word?

    is there a way to create form fields to tab into and type and or drop down selection fields in pages as you can with microsoft word?

    No

  • The screen on my ipod touch is stuck zoomed in. I turned it off and back and its still stuck zoomed in. I also tried to reset it and that didn't work either. Please help.

    The screen on my ipod touch is stuck zoomed in. I don't know how it happened I just looked down and it was like that. I have turned it off and back and even reset it but it still keeps zooming back in each time I turn it on. I can't unlock it because I can't see the numbers and it won't let me move around the screen. Please help.

    This is asked and answered often.  The foru search bar is on the right side of this page.
    It is also covered in the manual - zoom feature:
    iPod touch User Guide (For iOS 4.3 Software)
    Double tap with three fingers.

  • How can I select more than one bookmark at a time so that I can then open multiple bookmarks -- without the aggravation of going back to the list and selecting and opening each one.

    From my dozens of bookmarks, I often would like to open 5 or 6 of them at once -- perhaps a couple of weather reports, a couple of radio stations, a couple of other websites. But I see no way of doing this without laboriously finding a bookmark, selecting it, opening the website, then returning to the bookmarks, finding the second bookmark, selecting it, opening the website, and on and on. Surely there's a way for me to select multiple unrelated bookmarks and open them at the same time. Thanks much for your help. Don

    ''Actually there is a picture and better explanation in the corresponding History article''
    * ''http://kb.mozillazine.org/Viewing_the_browsing_history_-_Firefox ''
    Look where this picture is embedded in the article topic [http://kb.mozillazine.org/Viewing_the_browsing_history_-_Firefox#Selecting_history_items Selecting history items]
    * http://kb.mozillazine.org/images/Fx3_history_sidebar_selections2.png
    Selecting, viewing, and searching the sidebars and library lists is explained in both articles previously mentioned.
    Multiple selection is something built-in to a lot of applications and into all browsers, and yes you guessed correctly the favicon it the thing to the left of the bookmark and that is what is is called in all browsers. And if you look at selection you will find that it matches what you asked for, especially if you were to do a search from the search bar on the bookmark or history sidebar. But there is also no problem opening up a single bookmark or history item into a new tab, with either Ctrl+click or Ctrl+Shift+click in the area to the right of the favicon either.
    However I would suggest making a change to your configuration options so the the same keyboard shortcut is used from a link and from your bookmarks. See those keyboard shortcuts in the following along with the footnotes just below the table for them in
    * http://www.mvps.org/dmcritchie/firefox/keyboard.htm

  • Hello, I've updated the iPhone I have got I have a problem I hope you respond to some of the applications no longer work, such as the safari and skype and many applications are no longer working with the ios7.0.4

    Hello, I've updated the iPhone I have got I have a problem I hope you respond to some of the applications no longer work, such as the safari and skype and many applications are no longer working with the ios7.0.4

    Standard troubleshooting...
    1. Try a Restart by pressing the sleep/lock button until you see the slider.  Slide to power off.  Restart by pressing the sleep/lock button until you see the Apple logo.
    2. Try a Reset by pressing the home and sleep buttons until you see the Apple logo. Takes about 5-15 secs of button holding and you won't lose any data or settings.
    3. Remove apps from Recently Used (multi-tasking) list...
    - From any Home Screen, double tap the home button to bring up the Recents List
    - Swipe up on the app preview card to remove it from the list
    - Press the home button when done.
    4. If still a problem restore with your backup.
    5. If still a problem restore as new, i.e. without your backup. See how it runs with nothing synced to it.
    6. If still a problem, it's likely a hardware issue.

  • What is the diffrence between BAPI and RFC and business object

    Hi Experts,
    Can anybody tel me what is the diffrence between RFC and BAPI , and also what is ther relation with business object?
    Thanx in advance.
    Nilesh Hiwale

    Hi,
    BAPI's are associated with Business Objects and also they are RFC enabled.
    But RFC's are the FM's which can be called from external systems, those FM's can be used in many places based on the applications..
    Check these Links
    whats the difference between BAPI and RFC??
    Diff. Between BAPI and RFC
    Regards
    Kiran

  • Help! I received a message on my iPhone that "phone Number Added to iPad4 [NAME of IPAD] is now using [PHONE NUMBER] for FaceTime and iMessage" and it is not my iPad!! What do I do, how do I shut them out??

    Help! I received a message on my iPhone that "phone Number Added to iPad4 [NAME of IPAD] is now using [PHONE NUMBER] for FaceTime and iMessage" and it is not my iPad!! What do I do, how do I shut them out??

    Use a strong password and set up Two Step Verification on your account.
    http://support.apple.com/kb/ht5570

  • HT201272 If I already downloaded my songs then accidentally deleted them from my computer, how can I redownload them? Itunes store shows them as downloaded and unless I go through and try and repurchase each song individually, it wont let me redownload. h

    How ccan I redownload my music to the same computer. Downloaded, then deleted, now i tunes won't let me redownload, because I already downloaded. If I go through and try and repurchase the songs it will download them for me but I don't want to have to do that 250 times.

    You need to delete the broken entries first, then the tracks will show up with the iCloud download symbols in your purchased histroy and IIRC you can download them all in one go.
    tt2

  • My phone is unable to make outgoing calls, receiving them and sending and receiving both SMS and IM are all ok? Anyone have solutions?

    I have an IPhone 4 , which is on a Vodafone network, when I try and make outgoing calls it says 'call failed' . I am still able to send/receive SMS and IM and receiving calls is also so problem, does anyone have any solutions?

    You need to contact Vodafone.

  • My new purchases will not sync into my playlist and get and will not show up on my iphone playlist of the same name, and I just tried to sync a new cd into my library and it is not showing up on my iphone.

    My new purchases will not sync into my playlist and get and will not show up on my iphone playlist of the same name, and I just tried to sync a new cd into my library and it is not showing up on my iphone.

    Hello there, Capricious13.
    There are great pointers in the following Knowledge Base article. Depending on where you see the content and where you want to get it to, this should guide you to putting it in the right place:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/ht2519
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro D.

  • How do I get iTunes to keep "The and A and An" when sorting?

    iTunes for Windows strips of "The" and "A" and "An" from the artist and album names when it is sorting. How do I get it to stop? I have 6,000 files that I've just imported and it is ordering them in completely the wrong way for me.
    It lists "The Beatles" under "B" and I want it under "T" for "THE Beatles" and so on. I don't want to have to change these one by one obviously because there are too many. I would like to select an option that leaves the full titles alone when sorting.
    How can I do this?

    Over 6000 people have downladed the script to get around this after a fashion. Is it still required?

  • My new ipod touch 4g doesn't let me download apps, it just says type in Apple ID password and when i do it asks for it again and again and again....

    My new ipod touch 4g doesn't let me download apps, it just says type in Apple ID password and when i do it asks for it again and again and again.... what should i do?

    I've got the same problem as well. When i connect all i see is "set up your iphone" screen. It worked perfectly fine a couple of weeks back when I last synced but, doesn't sycn anymore.
    Any help would be appreciated.

Maybe you are looking for

  • Syncing iPhone and Mac and the room needed on iPhone

    Evening Forum is it me or when syncing my iPhone do i notice that the room needed to swap stuff over is used in a strange way? for example [and its not exact i know so go with my sizes here], my 32GB iphone has say 30GB left after apps and other thin

  • Can I move downloads from one comeputer to another?

    I have downloaded music at work on my work computer and at home on my other computer is there a way for me to get the ones I downloaded at work on my home computer? I hope so. What happens if your computer crashes and you loose all of your iTunes Mus

  • Why doesn't my touch ID work?

    Every time I try to set it up it says failed and to try again.  It won't let me even put my finger on the home button before it says failed. I completely erased and reset the phone and tried again, but it still does the same thing.

  • Error Message..Not Authorized to Synch music??

    I recently bought an ipod and bought a few tunes, which I tried to synch to my ipod. When I try to do this I recieve the following error message: "Some of the items in the itunes library were not copied to the ipod because you are not authorized to p

  • Sata controllers for Apple SSD TS1288 media Macbook Pro 2010?

    Hello, I want install Win 7 64bits with bootcamp but I can't because in the first step of the installation, the system can't recognize my HD SSD, and ask me if I've a controllers in another suport how is USB or DVD. Thank u so much! I wait your respo