Jump to content
LaunchBox Community Forums

Game Details / XAML string questions


Recommended Posts

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:

image.thumb.png.0d28348c057a0fc01f059d3120be9c3d.png

 

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by essjaygee
Added some punctuation to make a point clearer
Link to comment
Share on other sites

  • 2 weeks later...

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

image.thumb.png.594beae7684fddf30b1a3f3f04aa8ad7.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
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...