Hi, <
I am using following style for displaying ListBoxItems in my application and it was working fine for me untill I tried to trim (TextTrimming) the items that were too large to be displayed completely. I tried using TextBlock instead of ContentPresenter but couldn't
associate the Text property with style of ListBox. Can I Use TextBlock.TextTrimming property with content presenter ? if yes , how? or Should I stick to TextBlock option ? if yes , how to bind the Text property with ListBoxItem/ListBox?
<Setter x:Uid="Setter_10" Property="OverridesDefaultStyle" Value="true" />
<Setter x:Uid="Setter_11" Property="FocusVisualStyle" Value="{x:Null}" />
<Setter x:Uid="Setter_12" Property="Background" Value="Transparent" />
<Setter x:Uid="Setter_13" Property="BorderBrush" Value="Transparent" />
<Setter x:Uid="Setter_14" Property="BorderThickness" Value="0" />
<Setter x:Uid="Setter_15" Property="FontFamily" Value="{StaticResource baseUIFont}" />
<Setter x:Uid="Setter_16" Property="FontSize" Value="25" />
<Setter x:Uid="Setter_17" Property="FontWeight" Value="Regular" />
<Setter x:Uid="Setter_18" Property="Foreground" Value="White" />
<Setter x:Uid="Setter_19" Property="HorizontalContentAlignment" Value="Left" />
<Setter x:Uid="Setter_20" Property="VerticalContentAlignment" Value="Center" />
<Setter x:Uid="Setter_21" Property="Padding" Value="0,0,0,0" />
<Setter x:Uid="Setter_22" Property="Template">
<Setter.Value>
<ControlTemplate x:Uid="ControlTemplate_2" TargetType="{x:Type ListBoxItem}" x:Name="listboxitemctrltemp">
<StackPanel x:Uid="StackPanel_1" >
<Border Name ="Brdtemplate" Margin="0,0,0,0" VerticalAlignment="Top" Height="50"
x:Uid="Border_4" Background="{TemplateBinding Background}"
BorderBrush="Transparent"
BorderThickness="0"
Padding="{TemplateBinding Padding}">
<!--<ContentPresenter Margin="25,0,0,0"HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="Center"
Width="300" TextBlock.FontSize="25" x:Uid="ContentPresenter_1" x:Name="ContentSite">
</ContentPresenter>-->
</TextBlock>
</
Border><
Rectangle x:Uid="Rectangle_1" Opacity="0.25" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="0,0,0,0" Width="Auto" Height=".5" Fill="Black" /><
Rectangle x:Uid="Rectangle_2" Opacity="0.25" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="0,1,0,0" Width="Auto" Height=".5" Fill="White" /></
StackPanel><
ControlTemplate.Triggers><
Trigger x:Uid="Trigger_1" Property="IsSelected" Value="true"><
Setter x:Uid="Setter_23" Property="Background" Value="#5059d2ff" /></
Trigger><
Trigger Property="IsMouseOver" Value="True"><
Setter TargetName="Brdtemplate" Property="Background" Value="#5059d2ff" /></
Trigger></
ControlTemplate.Triggers></
ControlTemplate></
Setter.Value></
Setter><
Style.Triggers><
Trigger x:Uid="Trigger_2" Property="IsEnabled" Value="false"><
Setter x:Uid="Setter_24" Property="Foreground" Value="Gray" /></
Trigger></
Style.Triggers></
Style>Thanks.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.