문제

나는 현재 WPF를 가지고 놀고 있으며 이제 일반적인 DataEntry 창 (20 개 이상의 텍스트 상자 및 물건)의 레이아웃이 무엇인지 궁금합니다.

ATM I '이와 같은 그리드 객체를 사용하고 있습니다 (기본 샘플)

    <Grid Margin="2,2,2,2">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>

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

            <Label Grid.Row="0" Grid.Column="0">Vorname:</Label>
            <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Surname, UpdateSourceTrigger=PropertyChanged}" ></TextBox>

            <Label Grid.Row="1" Grid.Column="0">Nachname:</Label>
            <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=ChristianName, UpdateSourceTrigger=PropertyChanged}"></TextBox>

            <Label Grid.Row="2" Grid.Column="0">Strasse (Wohnsitz):</Label>
            <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Path=Street1, UpdateSourceTrigger=PropertyChanged}"></TextBox>

            <Label Grid.Row="3" Grid.Column="0">Ort (Wohnsitz):</Label>
            <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=Town1, UpdateSourceTrigger=PropertyChanged}"></TextBox>

            <Label Grid.Row="4" Grid.Column="0">Postleitzahl (Wohnsitz):</Label>
            <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Path=PostalCode1, UpdateSourceTrigger=PropertyChanged}"></TextBox>

            <Label Grid.Row="5" Grid.Column="0">Bundesland (Wohnsitz):</Label>
            <TextBox Grid.Row="5" Grid.Column="1" Text="{Binding Path=State1, UpdateSourceTrigger=PropertyChanged}"></TextBox>

            <Label Grid.Row="6" Grid.Column="0">Land (Wohnsitz):</Label>
            <TextBox Grid.Row="6" Grid.Column="1" Text="{Binding Path=Country1, UpdateSourceTrigger=PropertyChanged}"></TextBox>

            <Label Grid.Row="7" Grid.Column="0">Zusatz (Wohnsitz):</Label>
            <TextBox Grid.Row="7" Grid.Column="1" Text="{Binding Path=AdditionalAdrInfo1, UpdateSourceTrigger=PropertyChanged}"></TextBox>

    </Grid>

기본적으로 이것은 모든 레이아웃 요구를 충족하지만 3 행에 새 텍스트 상자를 추가하는 것과 같이 무언가를 변경하려면 어떻게해야합니까?

현재 나는 모든 단일 그리드를 변경해야합니다.

다른 사람들은 복잡한 데이터 엔트리 윈도우를 어떻게 배치합니까?

티아

도움이 되었습니까?

해결책

Karl Shifflett는 또한 WPF에서 LOB 형태에 대한 좋은 접근 방식을 가지고 있습니다. http://karlshifflett.wordpress.com/2008/10/23/wpf-silverlight-lob-layout-searching-for-a-better-solution/

다른 팁

개인적으로 저는 Autogrid의 열렬한 팬입니다. http://www.codeplex.com/wpfcontrib/wiki/view.aspx?title=autogrid&referringtitle=home

어떤 사람들은 중첩을 사용합니다 StackPanel이 문제를 "해결"하지만 또 다른 문제를 소개하는 IMHO (코드 bloat). 이것을 해결하는 가장 좋은 방법은 어린이를 열에 연속적으로 배치하는 자신의 패널을 작성하는 것입니다. 이전 프로젝트 에서이 작업을 수행했으며 여러 가지 장점이 있습니다.

  • 더 읽기 쉽고 간결한 xaml
  • XAML을 유지하기가 더 쉽습니다
  • 더 빠른 성능

사용법은 다음과 같이 보였습니다.

<local:FieldPanel>
    <Label>Field 1:</Label>
    <TextBox/>

    <Label>Field 2:</Label>
    <TextBox/>

    <Label>Field 3:</Label>
    <TextBox/>
</local:FieldPanel>

다음은 더 양식 레이아웃이 있습니다 http://www.slideshare.net/ackava/ui-atoms-form-layout

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top