Forum Xamarin.Forms

Content View and data grid

ElPiponElPipon COMember ✭✭
edited September 2017 in Xamarin.Forms

Hello everyone

I am using the xamarin forms datagrid library, with which I am displaying the datagrid in a content view. As I do to the grid can also put on the same page other controls of xamarin without the grid occupy the entire space of the page?

My code:
<ContentView BackgroundColor="White" Padding="5" HeightRequest="200">
        <StackLayout Orientation="Horizontal" Padding="5,5,5,5">
            <Button
      Text="Chequeados"
      BackgroundColor="Red"
      TextColor="Black"
      BorderWidth="1"
      BorderColor="Black"
      Command="{Binding ChequeadoCommand}"
      HorizontalOptions="StartAndExpand"
      VerticalOptions="Start">

            </Button>
            <Button
          Text="No Chequeados"
          BackgroundColor="Blue"
          TextColor="Black"
          BorderWidth="1"
          BorderColor="Black"
          Command="{Binding NoChequeadoCommand}"
          HorizontalOptions="Fill"
          VerticalOptions="End">

            </Button>
        </StackLayout>
        <SearchBar
            Placeholder="Buscar..."
            Text="{Binding Filter, Mode=TwoWay}"
            TextColor="Black"
            SearchCommand="{Binding SearchProductCommand}">
        </SearchBar>
        <!--<dg:DataGrid ItemsSource="{Binding Productos}" SelectionEnabled="True" SelectedItem="{Binding SelectItemAsync}"
                         RowHeight="40" HeaderHeight="50" BorderColor="#CCCCCC" HeaderBackground="#E0E6F8"
                         ActiveRowColor="#8899AA">
                <dg:DataGrid.HeaderFontSize>
                    <OnIdiom  x:TypeArguments="x:Double">
                        <OnIdiom.Tablet>15</OnIdiom.Tablet>
                        <OnIdiom.Phone>12</OnIdiom.Phone>
                    </OnIdiom>
                </dg:DataGrid.HeaderFontSize>
                <dg:DataGrid.Columns>
                    <dg:DataGridColumn x:Name="columncodigo" Title="Codigo" PropertyName="Codigo"/>
                    <dg:DataGridColumn x:Name="columnean" Title="EAN" PropertyName="EAN"/>
                    <dg:DataGridColumn x:Name="columndescripcion" Title="Descripcion" PropertyName="Descripcion" SortingEnabled="True"/>
                    <dg:DataGridColumn x:Name="columnprecio" Title="Precio" PropertyName="Precio" />
                </dg:DataGrid.Columns>
                <dg:DataGrid.RowsBackgroundColorPalette>
                    <dg:PaletteCollection>
                        <Color>#F2F2F2</Color>
                        <Color>#FFFFFF</Color>
                    </dg:PaletteCollection>
                </dg:DataGrid.RowsBackgroundColorPalette>
            </dg:DataGrid>-->
    </ContentView>

Posts

  • JohnHardmanJohnHardman GBUniversity admin
    edited September 2017

    @ElPipon - Some of your XAML is missing. You need to put three back-apostrophes/back-ticks on the line before the XAML and three on the line after the XAML to get it to format correctly.

    Here's one back-apostrophes - copy this 3 times: `

  • ElPiponElPipon COMember ✭✭
    edited September 2017

    Thanks, can help me or you know who can help me?

  • JohnHardmanJohnHardman GBUniversity admin

    @ElPipon -

    I don't know what appearance you want, but why not include the horizontal StackLayout, the SearchBar and the DataGrid in a new vertical StackLayout?

    Depending on which DataGrid it is, you might need to specify HeightRequest on the DataGrid.

Sign In or Register to comment.