Как это исправить?
Например, вы можете определить Style
для Border
как отдельный ресурс:
<ItemsControl>
<ItemsControl.Resources>
<Style x:Key="BorderStyle" TargetType="Border">
<EventSetter Event="MouseLeftButtonDown" Handler="UIElement_MouseLeftButtonDown" />
</Style>
</ItemsControl.Resources>
<ItemsControl.Style>
<Style TargetType="{x:Type ItemsControl}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Items.Count, RelativeSource={RelativeSource Self}}" Value="0">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderThickness="2" BorderBrush="Black" CornerRadius="2" Padding="10" Margin="10"
Style="{StaticResource BorderStyle}">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" >Keine Dateien angehängt</TextBlock>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</ItemsControl.Style>
</ItemsControl>