2011-10-26 11 views
0

グリッド内にテキストボックスがあり、グリッド内の列幅にバインドしようとしているスタイルがテキストボックスに適用されています。リソースディクショナリ内のグリッド幅にバインドする

window.xaml

<Grid.RowDefinitions> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

    <Label Content="Register User" Grid.Column="0" Grid.Row="0" Style="{StaticResource LabelStyle}"/> 
    <Label Content="User Name: " Grid.Column="0" Grid.Row="1" Style="{StaticResource LabelStyle}"/> 


    <TextBox Grid.Column="1" Grid.Row="1" Style="{StaticResource TextBoxStyle}"/> 
</Grid> 

DefaultStyle.xaml

<Style TargetType="{x:Type Label}" x:Key="LabelStyle"> 
    <Setter Property="HorizontalAlignment" Value="Left"/> 
    <Setter Property="VerticalAlignment" Value="Center"/> 
</Style> 

<Style TargetType="{x:Type TextBox}" x:Key="TextBoxStyle"> 
    <Setter Property="HorizontalAlignment" Value="Left"/> 
    <Setter Property="VerticalAlignment" Value="Center"/> 
    <Setter Property="Width" Value="{<!--?????????--!>}"/> 
</Style> 

これをバインドする方法をいくつか試しましたが、解決できません。代わりに幅を設定するので

答えて

2

、ちょうどHorizontalAlignment="Stretch"

<Setter Property="HorizontalAlignment" Value="Stretch"/> 
を設定
関連する問題