Jump to content
LaunchBox Community Forums

How to display Alternate Names in Game Details view?


Recommended Posts

I'm modifying the Default LB theme and I'm trying to figure out how to display the Alternate Names for a given game in the Game Details panel when a game is selected. 

The ListContentView.xaml shows that it's possible to do this, at least in the list view:

<DataGridTemplateColumn CellStyle="{StaticResource DataGridCellStyle}" CanUserSort="True" SortMemberPath="AlternateNames">
    <DataGridTemplateColumn.Header>
        <TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.AltNamesLabel}" />
    </DataGridTemplateColumn.Header>
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding AlternateNames}" TextTrimming="WordEllipsis" />
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

However, this doesn't work in the GameDetailsView.xaml (presumably because this code is for use in a DataGrid, while the GameDetails uses a ScrollViewer?).

Unlike the other items shown on the GameDetail view, I'm gathering that you can't just add a TextBlock with Text="{Binding AlternateNames}" because there could be multiple AlternateNames, so you have a many-to-one relationship.

However, the default GameDetailsView.xaml does include an entry for CustomFields, which can also have multiple entries. It does so using an ItemsControl:

                        <ItemsControl ItemsSource="{Binding CustomFields}" Focusable="False">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding}" Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.ForegroundBrush}" TextWrapping="Wrap" Margin="0,0,0,4" />
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>

 

But for some reason, when I try using this code by replacing "{Binding CustomFields}" with "{Binding AlternateNames}", it doesn't work.

I'm probably missing something really basic / obvious... but can anyone point me in the right direction?

 

 

 

Clipboard03.png

Link to comment
Share on other sites

Thanks very much! That definitely helped and now I'm closer, but still not quite there.

The GameDetails is now displaying one entry for each of the alternate names, but instead of actually showing me the names, it's just showing the full namespace for the AlternateNames object: "Unbroken.LaunchBox.Data.AlternateName". You can see what I mean in the screenshot below.

Here's the code I'm using:

<ItemsControl ItemsSource="{Binding Game.AlternateNames}" >
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" Foreground="#FFFFFFFF" />
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

So the AlternateNames object/interface is being correctly accessed, but I'm not sure what property to use in the <TextBlock Text={Binding}" /> to actually get it to display the name. For the CustomFields property, simply using "{Binding}" is sufficient. But that doesn't work here, and neither does "{Binding Games.AlternateNames}" or "{Binding AlternateNames}" or "{Binding Games}"

I feel like I'm really close here. Do you have any other thoughts or suggestions?

Thanks again.

Clipboard03.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...