Ask a questionAsk a question
 

AnswerBest way to avoid repeating code?

  • Wednesday, November 04, 2009 1:45 AMsaxisa Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    If  have something like this:
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
             .... etc, etc,
        </Grid.RowDefinitions>
        <!-- And then I need to do something like this: -->
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="100*" />
            </Grid.ColumnDefinitions>
            <view:myDataView Grid.Column="0" x:Name="Dataset1" />
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="10*" />
                <ColumnDefinition Width="90*" />
            </Grid.ColumnDefinitions>
            <view:myDataView Grid.Column="0" x:Name="Dataset2" />
    </Grid>

    How can I simplify this so I dont keep copying the same code?  Also, instead of a view, could I use a viewmodel?

Answers

All Replies