shro2016 Posted July 10, 2017 Share Posted July 10, 2017 I am building a new theme currently but really need to be able to reformat the Selectedgame.Genresstring binding so that it is not presented as genre1;genre2;genre3 as this looks very messy when displayed on the theme. Does anyone know of any way to return only the first genre from the list or alternatively how to reformat the string so that the ; are removed? Quote Link to comment Share on other sites More sharing options...
Hexxxer Posted July 10, 2017 Share Posted July 10, 2017 (edited) what is it returning there? a list? I can't check right now but if it is just a single genre you could try this. string Genre = Selectedgame.Genresstring.Replace(';', '')); If it is a list of strings you can break it into an array using split string [] Genres = Selectedgame.Genresstring.Split(';'); and then just call on Genre[0] to get the first genre. Again, can't test this ATM so it may not be 100% correct. Edited July 10, 2017 by Hexxxer Quote Link to comment Share on other sites More sharing options...
shro2016 Posted July 23, 2017 Author Share Posted July 23, 2017 On 7/10/2017 at 10:40 PM, Hexxxer said: what is it returning there? a list? I can't check right now but if it is just a single genre you could try this. string Genre = Selectedgame.Genresstring.Replace(';', '')); If it is a list of strings you can break it into an array using split string [] Genres = Selectedgame.Genresstring.Split(';'); and then just call on Genre[0] to get the first genre. Again, can't test this ATM so it may not be 100% correct. @Hexxxer Thanks for your help with this though unfortunately I have failed to get this working with the suggestions above. I cannot find a way to declare variables within the XAML file without generating an error - where should these lines be placed? Quote Link to comment Share on other sites More sharing options...
eatkinola Posted July 23, 2017 Share Posted July 23, 2017 You'll probably need to use code-behind for this. You can write a converter to get this info. 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.