Jump to content
LaunchBox Community Forums

Recommended Posts

Posted

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

Posted

I'd have to double check, but pretty sure on GameDetails you need to include "Game." (without quotes) on the bindings. So instead of "AlternateNames" you would use "Game.AlternateNames" (both without quotes)

Posted

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

  • 5 months later...
Posted

For some reason just now seeing the post my apologies @giotte.

Basically do everything like they have above except in the textblock instead if Text="{Binding}", you want Text="{Binding Name}"

Posted

Based on the example above, it would be:

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

 

Posted

Yep, I can confirm that Text="{Binding Name}" works. Thanks CBeats and faeran for your help; I knew it had to be something simple.

Nice to finally have this working.

  • 1 month later...
  • 2 years later...
Posted

 

Picture.png.d4c94139d53dcce81c208d62a204c478.png

This is the result that appears to me. Everything is ok but the region/context that the displayed name refers to is not shown. The ideal would be as shown in the second image (considering all the writings with the same font and the writings on the left side of one color and those on the right side of another). Could it be done?

 

Picture2.png.bfb95b2806a3ad8ba7ae466cafda5670.png

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...