I have an Ellipse in each TabControl header which is to highlight blue if there is any items selected in the DataGrid below it, otherwise it should be Transparent. At the moment I have the Trigger in reverse so if the DataGrid SelectedItems.Count is 0 it is Transparent, if there is someway to have the default as transparent that would be nice.
Note: It will have multiple tabs and associated DataGrids.
How can I get the Style Trigger working correctly on the Ellipse?
<TabControl Name="tcGeometry" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5" ItemsSource="{Binding GEOMETRIES}" >
<TabControl.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding DISPLAY_NAME}" Margin="0,0,25,0"/>
<Ellipse x:Name="SelectionIndicator"
Width="8" Height="8"
Stroke="Black"
Fill="Blue"
StrokeThickness="1"
HorizontalAlignment="Right"
VerticalAlignment="Top">
<Ellipse.Style>
<Style TargetType="{x:Type Ellipse}">
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedItems.Count, ElementName=dgAudit}" Value="0">
<Setter Property="Fill" Value="Transparent" />
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
</Grid>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<Grid ShowGridLines="False">
<DataGrid Name="dgAudit"
Grid.Row="0"
Grid.Column="0"
IsReadOnly="True"
ItemsSource="{Binding GEOM_ASSET_OC_LIST}"
HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
AutoGenerateColumns="False"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
RowDetailsVisibilityMode="Collapsed"
RowHeaderWidth="30" />
</Grid>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>

Don't set the a local value for the
Fillproperty of theEllipse. Set the default value in aStylesetter.Local values take precedence over values set in styles: https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/dependency-property-value-precedence
You may also have to bind to the
Countproperty of a source collection that keeps track of the selected items rather than binding to theSelectedItemsproperty of theDataGridelement. This is because aTabControlby default unloads the visual tree of the unselect tab when you switch tabs:How to stop Wpf Tabcontrol to unload Visual tree on Tab change