J'ai un ItemsControl, le ItemsPanel est faite par un DockPanel.Remplissez tout l'espace disponible dans ItemsComtrol avec la même largeur largeur des éléments
À l'intérieur du DockPanel, je peux avoir un, deux ou trois boutons. Le problème provient de la largeur des boutons: je veux les trois éléments de la même taille, mais les éléments prennent la taille dont ils ont besoin (le dernier élément prend l'excès de largeur car LastChildFill est vrai). Puis-je donner aux boutons la même largeur sans fournir leur taille manuellement?
<ItemsControl ItemTemplate="{StaticResource Template1}" ItemsSource="{Binding Path=options, Mode=OneWay}" ItemsPanel="{StaticResource Panel1}" HorizontalContentAlignment="Stretch"/>
<ItemsPanelTemplate x:Key="Panel1">
<DockPanel Height="Auto" Width="Auto" LastChildFill="True"/>
</ItemsPanelTemplate>
<DataTemplate x:Key="BasicasTemplateOpciones" DataType="{x:Type local:MyOption}">
<Grid HorizontalAlignment="Stretch">
<Button DataContext="{Binding}" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Stretch"/>
</StackPanel>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</DataTemplate>