FoggyFinder
On a `VM` part I have the `SomeItem` type:
```text/x-fsharp
type SomeItem = {
Index : int
IsCurrent : bool
}
```
and the `SomeItems:SomeItem[]` property.
On a `View` part I have a`ListBox` where I bind the `Items` and the `SelectedIndex` properties:
```xml
<ListBox
Items="{Binding SomeItems}"
SelectedIndex="{Binding CurrentIndex}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="{Binding IsCurrent, Converter={StaticResource b2bConv}}}"
BorderThickness="2">
<Grid />
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
```
(parts that unrelated to the Q were omitted)
Here, I use the `BoolToBrushConverter` converter to determine the color of a border depending on the `IsCurrent` property.
```text/x-fsharp
type BoolToBrushConverter() =
interface IValueConverter with
member this.Convert(value: obj, _, _, _): obj =
match value with
| :? bool as b ->
if b then Brushes.Green else Brushes.LightGray
| _ -> Brushes.Black
|> box
member this.ConvertBack(_, _, _, _): obj =
raise (System.NotImplementedException())
```
But now I want to get rid of this `IsCurrent` property since it's not very useful on a VM layer. For `WPF` I'd probably use `DataTrigger` but this feature is unsupported in Avalonia yet.
So how can I achieve the same look ?
Version of Avalonia: `0.9.11`
Top Answer
FoggyFinder
Instead of changing the border you can change the background of a `ListBoxItem` - the result would be the same.
To apply changes use next styles:
```xml
<ListBox.Styles>
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
<Setter Property="Background" Value="Green" />
</Style>
<Style Selector="ListBoxItem">
<Setter Property="Background" Value="LightGray" />
</Style>
</ListBox.Styles>
```
First one uses the `selected` pseudoclass (you can read more about that in the [docs](https://docs.avaloniaui.net/docs/styling/styles#pseudoclasses)).