Categories > Coding > C# >

[RQ] Auto style listbox items WPF

Posts: 3

Threads: 1

Joined: Mar, 2023

Reputation: 0

Posted

So the listbox automatically makes items from the Scripts folder. But how do i make it to also automatically add style to the items?

 

Like:

https://media.discordapp.net/attachments/981855036835524639/1089198391625523321/image.png

  • 0

SeizureSalad

i love femboys

Posts: 1158

Threads: 79

Joined: Mar, 2021

Reputation: 40

Replied

something.Style = FindResource("YourResourceKey") as Style;

  • 0

"Questionable intellegence, but I like the mystery" - CubeFaces

https://cdn.discordapp.com/attachments/1136067487847415848/1138948596679589898/sig.png

Akula

Pv.Akula

vip

Posts: 219

Threads: 14

Joined: Apr, 2018

Reputation: 37

Replied

attach listitem style to the listbox, any new item added should follow / be binded to that style

  • 0

Posts: 3

Threads: 1

Joined: Mar, 2023

Reputation: 0

Replied

@Akula,

 

There is no option to add listbox item style to listbox style. Only i can add listbox style to listbox, not listbox items style

  • 0

marcus__

S.K.I.D

vip

Posts: 444

Threads: 23

Joined: Nov, 2022

Reputation: 29

Replied

iirc you can use

			this.listboxthing.Items.Add(
				new ListBoxItem
				{
					Style = this.TryFindResource("listboxstyle") as Style,
				}
			);

am not the best at wpf tho

  • 0

!!!!!marcus__!!!!!#8611

https://cdn.discordapp.com/attachments/1066053366758780978/1078052772567597127/image.png

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )