/ / Comment puis-je obtenir un fond Texbox adapté à sa taille de marge? - wpf, xaml

Comment puis-je obtenir un fond Texbox adapté à sa taille de marge? - wpf, xaml

Une petite partie de mon interface utilisateur est écrite comme suit:

<StackPanel>
<Grid>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<StackPanel Grid.Column="0">
<TextBlock Text="Keywords" FontWeight="Bold" />
<TextBox Padding="2" Background="#eee" Margin="0,0,0,50"/>
</StackPanel>

<StackPanel Grid.Column="1">
<TextBlock Text="Exclusions" FontWeight="Bold" />
<TextBox Padding="2" Background="#eee" Margin="0,0,0,50"/>
</StackPanel>

</Grid>
<Next thingy>
</StackPanel>

Il crée correctement la marge d'un segment au suivant dans le StackPanel mais n'étire pas la couleur d'arrière-plan avec lui. Regarde.

entrer la description de l'image ici

Vous ne pouvez pas non plus taper passé une seule colonne detexte. J'aimerais que la TextBox s'étende verticalement pour que vous puissiez y écrire un paragraphe si vous le souhaitez. Y a-t-il un autre type de boîte que je devrais utiliser à la place?

Réponses:

0 pour la réponse № 1

Au lieu de mettre le fond Margin du TextBox à 50, vous pouvez définir son Height à 50.

Vous devriez également définir le AcceptsReturn propriété à true si vous souhaitez saisir plusieurs lignes:

<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<TextBlock Text="Keywords" FontWeight="Bold" />
<TextBox Padding="2" Background="#eee" Height="50" AcceptsReturn="True"/>
</StackPanel>
<StackPanel Grid.Column="1">
<TextBlock Text="Exclusions" FontWeight="Bold" />
<TextBox Padding="2" Background="#eee" Height="50" AcceptsReturn="True"/>
</StackPanel>
</Grid>
<TextBlock>next...</TextBlock>
</StackPanel>