WPF上的响应字体大小和控件

时间:2016-06-03 01:41:18

标签: c# wpf datagrid

我对 WPF 上的自适应设计有一些疑问。

第一个:

我在网格的一行内有一个控件;程序全屏运行,因此,控制非常小,如图中所示: enter image description here

DatePicker位于ViewBox内部以进行响应,但控件并未覆盖行的整个空间。

我应该怎样做才能涵盖所有空间?

这是我的XAML代码:

<Grid Grid.Row="4" Margin="0 1">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
         </Grid.ColumnDefinitions>
    <Viewbox Grid.Column="0" HorizontalAlignment="Left">
          <Label Background="Gainsboro" BorderBrush="Black" BorderThickness="1" Content="Fecha de Nacimiento:" />
     </Viewbox>
     <Viewbox Grid.Column="1" HorizontalAlignment="Left">
          <DatePicker Grid.Column="1" VerticalContentAlignment="Center"/>
     </Viewbox>
</Grid>

我的第二个问题是:

我有一个DataGrid,里面填充了从查询到REST服务的信息。它还全屏运行,问题是:

我可以做些什么来使所有文本在DataGrid中响应?

这是我的XAML代码:

<DataGrid x:Name="dtgClientes" Grid.Row="1" ItemsSource="{Binding lstClientes}" AutoGenerateColumns="False" SelectionMode="Single" SelectionUnit="FullRow" AlternatingRowBackground="WhiteSmoke" IsReadOnly="True" RowHeaderWidth="0">
<DataGrid.Resources>
    <Style TargetType="DataGridColumnHeader">
        <Setter Property="Background" Value="#066DCC"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
    </Style>
</DataGrid.Resources>
<DataGrid.Columns>
    <DataGridTextColumn Width="*" Binding="{Binding Persona.Nombre}">
        <DataGridTextColumn.Header>
            <TextBlock Text="Nombre" TextWrapping="Wrap"/>
        </DataGridTextColumn.Header>
    </DataGridTextColumn>
    <DataGridTextColumn Width="*" Binding="{Binding Persona.ApellidoPaterno}">
        <DataGridTextColumn.Header>
            <TextBlock Text="Apellido Paterno" TextWrapping="Wrap"/>
        </DataGridTextColumn.Header>
    </DataGridTextColumn>
    <DataGridTextColumn Width="*" Binding="{Binding Persona.ApellidoMaterno}">
        <DataGridTextColumn.Header>
            <TextBlock Text="Apellido materno" TextWrapping="Wrap"/>
        </DataGridTextColumn.Header>
    </DataGridTextColumn>
    <DataGridTextColumn Width="*" Binding="{Binding Persona.Telefono}">
        <DataGridTextColumn.Header>
            <TextBlock Text="Teléfono" TextWrapping="Wrap"/>
        </DataGridTextColumn.Header>
    </DataGridTextColumn>
    <DataGridTextColumn Width="*" Binding="{Binding Persona.TelefonoMovil}">
        <DataGridTextColumn.Header>
            <TextBlock Text="Móvil" TextWrapping="Wrap"/>
        </DataGridTextColumn.Header>
    </DataGridTextColumn>
    <DataGridTextColumn Width="*" Binding="{Binding Persona.Domicilio}">
        <DataGridTextColumn.Header>
            <TextBlock Text="Domicilio" TextWrapping="Wrap"/>
        </DataGridTextColumn.Header>
    </DataGridTextColumn>
    <DataGridTextColumn Width="*" Binding="{Binding Persona.FechaNacimiento}">
        <DataGridTextColumn.Header>
            <TextBlock Text="Fecha de Nacimiento" TextWrapping="Wrap"/>
        </DataGridTextColumn.Header>
    </DataGridTextColumn>
    <DataGridTextColumn Width="*" Binding="{Binding Persona.Rfc}">
        <DataGridTextColumn.Header>
            <TextBlock Text="RFC" TextWrapping="Wrap"/>
        </DataGridTextColumn.Header>
    </DataGridTextColumn>
    <DataGridTextColumn Width="*" Binding="{Binding Persona.Curp}">
        <DataGridTextColumn.Header>
            <TextBlock Text="CURP" TextWrapping="Wrap"/>
        </DataGridTextColumn.Header>
    </DataGridTextColumn>
</DataGrid.Columns>

0 个答案:

没有答案