essjaygee Posted April 30, 2022 Share Posted April 30, 2022 Hello all, I'm playing around with tweaking the game details view in the default LB theme, but I think that some some of the things I would like to do aren't possible in pure XAML. However, I'd appreciate any advice if I'm wrong. I've currently got the top of the game details view looking like this, and have 2 questions: 1. I'm currently displaying the publisher and developer in a TextBlock with a MultiBinding but would like to only show one of the values if they are identical, as they are for Battle Chess here. <TextBlock TextWrapping="Wrap" FontFamily="{Binding SmallFontFamily}" FontSize="{Binding SmallFontSize}" FontWeight="Bold" FontStyle="{Binding SmallFontStyle}" TextAlignment="Center"> <TextBlock.Text> <MultiBinding StringFormat="{}{0} / {1} ({2})"> <Binding Path="Publisher.Value" /> <Binding Path="Developer.Value" /> <Binding Path="ReleaseDate.Value" /> </MultiBinding> </TextBlock.Text> </TextBlock> I originally thought of having TextBlocks with a trigger that compares the data with another binding, but that doesn't seem to be possible. Am I missing something? 2. I'd like to display just the year portion of the date in the above too (e.g. "(1988)"). I found some threads indicating that it can't be done with the game details settings within LB itself, but is it possible to extract just the YYYY portion of the date in XAML? Or even just show the last 4 characters of the date string? Apologies if these are silly questions, but any and all help is appreciated. Thanks very much, Steve Quote Link to comment Share on other sites More sharing options...
C-Beats Posted May 2, 2022 Share Posted May 2, 2022 1) You'd have to change how you display the string and instead of using a single text block use something like a WrapPanel with several text blocks inside of it that you can control visibility independently on. Once you move to that set up you could use a DataTrigger in the style of the text block to set Visibility to Collapsed if the values are the same (I don't THINK you'll need a converter to do so, but fairly certain we have one built already for this purpose if you do). 2) Just set to string format to yyyy and it should work for what you want Quote Link to comment Share on other sites More sharing options...
essjaygee Posted May 6, 2022 Author Share Posted May 6, 2022 (edited) Thanks very much for replying, C-Beats. For (1) All the resources I can find indicate that it's only possible to compare to a literal or system value in a DataTrigger, unless you use a converter. This stackoverflow item describes exactly what I'm seeing when I try. Time to read up on how to use a converter and find out if there is something within LB I can use for that, as you mention... I've tried multiple ways of setting the string format for (2), within the multi-binding StringFormat param and extracting to a standalone TextBlock to just have a single value to format. However, the resulting value is always the full date ('dd/mm/yyyy' in my case). I feel sure I'm missing something obvious, or making a simple error in my thinking, so any and all advice is welcome <TextBlock TextWrapping="Wrap" FontFamily="{Binding SmallFontFamily}" FontSize="{Binding SmallFontSize}" FontWeight="Bold" FontStyle="{Binding SmallFontStyle}" TextAlignment="Center"> <TextBlock.Text> <MultiBinding StringFormat="{}{0} / {1} ({2:yyyy})"> <Binding Path="Publisher.Value" /> <Binding Path="Developer.Value" /> <Binding Path="ReleaseDate.Value" /> </MultiBinding> </TextBlock.Text> </TextBlock> <TextBlock Text="{Binding ReleaseDate.Value, StringFormat='{}{0:yyyy}'}" /> Thanks again Edited May 6, 2022 by essjaygee Added some punctuation to make a point clearer Quote Link to comment Share on other sites More sharing options...
essjaygee Posted May 15, 2022 Author Share Posted May 15, 2022 To update this, in case it helps anyone else, I've managed to work out what I was doing wrong in (2), thanks to studying faeran's excellent Neptune theme. In short, I had to change the context I was using to refer to the release date to be 'Game.ReleaseDate'. The TextBlock.Text now looks like: <TextBlock.Text> <MultiBinding StringFormat="{}{0} / {1} ({2:yyyy})"> <Binding Path="Game.Publisher" /> <Binding Path="Game.Developer" /> <Binding Path="Game.ReleaseDate" /> </MultiBinding> </TextBlock.Text> which does exactly what I was aiming to do with the year 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.