giotte Posted October 5, 2021 Share Posted October 5, 2021 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? Quote Link to comment Share on other sites More sharing options...
C-Beats Posted October 5, 2021 Share Posted October 5, 2021 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) Quote Link to comment Share on other sites More sharing options...
giotte Posted October 5, 2021 Author Share Posted October 5, 2021 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. Quote Link to comment Share on other sites More sharing options...
Retrofrogg Posted April 5, 2022 Share Posted April 5, 2022 Did you ever sort this? Quote Link to comment Share on other sites More sharing options...
C-Beats Posted April 5, 2022 Share Posted April 5, 2022 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}" Quote Link to comment Share on other sites More sharing options...
faeran Posted April 5, 2022 Share Posted April 5, 2022 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> Quote Link to comment Share on other sites More sharing options...
giotte Posted April 5, 2022 Author Share Posted April 5, 2022 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. Quote Link to comment Share on other sites More sharing options...
FlightRisk Posted May 17, 2022 Share Posted May 17, 2022 Do you have a screenshot of what it wound up looking like? Quote Link to comment Share on other sites More sharing options...
Colorman3605 Posted September 29 Share Posted September 29 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.