Creating an IsSelected Style in Studio
Posted: 19 Feb 2025, 06:09
Hi,
Very much enjoying digging into Studio - very powerful capability. I'm trying to do something i think basic in Studio - but am a bit stumped. Gone through the following steps to try and understand how to change style of a selected item in a ListBox
- I have set up a main page with page/grid/listbox;
- created the schema for a list item and another for a list box containing the list item schema (just a single string);
- created a sample data set and assigned it to root
- added a data template to the list item schema
- in the template, added a textblock under the grid and bound it to the list item schema string
- and bound the listbox in the navigator with the listbox schema
all behaves fine when i run
What i'm trying to do is change from the default mouseover and selected styles.
I can manage mouseover - as i open the data template for the listbox item schema, go to the styling on the right to add style. Then i can add a setter for mouseover - very nice.
However, when i try to do the same for IsSelected - i don't see this option in the properties.
I experimented some thinking maybe i should have a listboxitem in the data template rather than a textBlock - however, when i try and create a binding for the listboxitem directly, it consistently crashes Studio.
I thought then i needed to add a listBoxItem element and a textblock underneath - and while i am able to now find IsSelected as an option - the style does not come through and i get an odd intermittent behavior when i select - it sporadically updates the selected cell with the default color. So, not sure if this parented approach of TextBlock to ListBoxItems works.
I looked through documents and forums - but couldn't find something similar - and went through the Squad code - but couldn't reverse engineer what steps were taken in Studio (i'm trying to working strictly through studio without hand editing the XAML under the hood)
Any guidance would be appreciated.
Cheers!
Very much enjoying digging into Studio - very powerful capability. I'm trying to do something i think basic in Studio - but am a bit stumped. Gone through the following steps to try and understand how to change style of a selected item in a ListBox
- I have set up a main page with page/grid/listbox;
- created the schema for a list item and another for a list box containing the list item schema (just a single string);
- created a sample data set and assigned it to root
- added a data template to the list item schema
- in the template, added a textblock under the grid and bound it to the list item schema string
- and bound the listbox in the navigator with the listbox schema
all behaves fine when i run
What i'm trying to do is change from the default mouseover and selected styles.
I can manage mouseover - as i open the data template for the listbox item schema, go to the styling on the right to add style. Then i can add a setter for mouseover - very nice.
However, when i try to do the same for IsSelected - i don't see this option in the properties.
I experimented some thinking maybe i should have a listboxitem in the data template rather than a textBlock - however, when i try and create a binding for the listboxitem directly, it consistently crashes Studio.
I thought then i needed to add a listBoxItem element and a textblock underneath - and while i am able to now find IsSelected as an option - the style does not come through and i get an odd intermittent behavior when i select - it sporadically updates the selected cell with the default color. So, not sure if this parented approach of TextBlock to ListBoxItems works.
I looked through documents and forums - but couldn't find something similar - and went through the Squad code - but couldn't reverse engineer what steps were taken in Studio (i'm trying to working strictly through studio without hand editing the XAML under the hood)
Any guidance would be appreciated.
Cheers!