私は、colspan (私はカレンダーを実装しています) で項目 (ボタン) を配置するテンプレートのグリッドを持つ ItemControls を持っています。ボタンへのテキストが大きすぎると、ボタンの幅が colspan を超えます。超過したテキストを非表示にする方法はありますか?
編集
xaml:
<ItemsControl Grid.Column="1" ItemsSource="{Binding Prenotazioni}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.Style>
<Style>
<Setter Property="Grid.Background">
<Setter.Value>
<MultiBinding Converter="{StaticResource GridColumnsDefinitionsSetter}">
<Binding RelativeSource="{RelativeSource Self}" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="Periodo" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="StartDate" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="EndDate" />
<Binding Path="." />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</Grid.Style>
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button
Command="{x:Static local:Timeline.SelectCommand}"
CommandTarget="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}}"
CommandParameter="{Binding .}">
<Button.ToolTip>
<local:SchedaServizioPrenotato />
</Button.ToolTip>
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="LightYellow"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Prenotazione.Annullata}" Value="True">
<Setter Property="Background" Value="LightSalmon"/>
<Setter Property="Opacity" Value="0.4"/>
</DataTrigger>
<DataTrigger Binding="{Binding Prenotazione.Confermata}" Value="True">
<Setter Property="Background" Value="LightBlue"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<TextBlock Text="{Binding Prenotazione.Nominativo}" TextTrimming="WordEllipsis"/>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Grid.Column">
<Setter.Value>
<MultiBinding Converter="{StaticResource ItemColumnSetter}">
<Binding RelativeSource="{RelativeSource Self}" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="Periodo" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="StartDate" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="EndDate" />
<Binding Path="Periodo.Inizio" />
<Binding Path="Periodo.Fine" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Grid.Row">
<Setter.Value>
<MultiBinding Converter="{StaticResource ItemRowSetter}">
<Binding RelativeSource="{RelativeSource Self}" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="Periodo" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="StartDate" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="EndDate" />
<Binding Path="." />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}" Path="DataContext" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Grid.ColumnSpan">
<Setter.Value>
<MultiBinding Converter="{StaticResource ItemColumnSpanSetter}">
<Binding RelativeSource="{RelativeSource Self}" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="Periodo" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="StartDate" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="EndDate" />
<Binding Path="." />
<Binding Path="Periodo.Inizio" />
<Binding Path="Periodo.Fine" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="FrameworkElement.Visibility">
<Setter.Value>
<MultiBinding Converter="{StaticResource ItemVisibilitySetter}">
<Binding RelativeSource="{RelativeSource Self}" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="Periodo" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="StartDate" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="EndDate" />
<Binding Path="Periodo.Inizio" />
<Binding Path="Periodo.Fine" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
編集
わかりやすくするために、Grid.Background コンバーターに列定義を設定します。