<sfGrid:GridTextColumn MappingName="ShipCity" IsHidden="{Binding HideCityColumn}">
<sfGrid:GridTextColumn.HeaderTemplate>
<DataTemplate>
<Grid BackgroundColor="DarkBlue">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<Button x:Name="city_Button" Grid.Column="0" Grid.Row="0" Text="<" Clicked="City_Button_Clicked" TextColor="White"BackgroundColor="#2862f7"/>
<Label VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" Text="City" Grid.Row="0" Grid.Column="1"TextColor="White" BackgroundColor="Transparent"/>
</Grid>
</DataTemplate>
</sfGrid:GridTextColumn.HeaderTemplate>
</sfGrid:GridTextColumn>
<sfGrid:GridTextColumn MappingName="ShipCountry" IsHidden="{Binding HideCountryColumn}">
<sfGrid:GridTextColumn.HeaderTemplate>
<DataTemplate>
<Grid BackgroundColor="DarkBlue">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<Label VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" Text="Country" Grid.Row="0" Grid.Column="0"TextColor="White" BackgroundColor="Transparent"/>
<Button x:Name="country_Button" Grid.Column="1" Grid.Row="0" Text=">" Clicked="Country_Button_Clicked" TextColor="White"BackgroundColor="#2862f7"/>
</Grid>
</DataTemplate>
</sfGrid:GridTextColumn.HeaderTemplate>
</sfGrid:GridTextColumn>
|
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
dataGrid.GridStyle = new CustomStyle();
}
private void City_Button_Clicked(object sender, EventArgs e)
{
this.viewModel.HideCityColumn = !this.viewModel.HideCityColumn;
this.viewModel.HideCountryColumn = !this.viewModel.HideCountryColumn;
}
private void Country_Button_Clicked(object sender, EventArgs e)
{
this.viewModel.HideCityColumn = !this.viewModel.HideCityColumn;
this.viewModel.HideCountryColumn = !this.viewModel.HideCountryColumn;
}
} |
<RelativeLayout x:Name="relativeLayout">
<sfGrid:SfDataGrid x:Name="dataGrid"
AutoGenerateColumns="False"
ColumnSizer="Star"
HeaderRowHeight="80"
VerticalOverScrollMode="None"
ItemsSource="{Binding OrderInfoCollection}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=1,
Constant=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=1,
Constant=0}">
<sfGrid:SfDataGrid.Columns>
<sfGrid:GridTextColumn MappingName="Customer"/>
.. .
</sfGrid:SfDataGrid.Columns>
</sfGrid:SfDataGrid>
</RelativeLayout>
|
private void DataGrid_GridLoaded(object sender, GridLoadedEventArgs e)
{
var point = this.dataGrid.RowColumnIndexToPoint(new RowColumnIndex(1, 0));
BoxView boxView = new BoxView();
boxView.HeightRequest = 1.5;
boxView.Color = Color.Red;
boxView.BackgroundColor = Color.Red;
boxView.Opacity = 100;
this.relativeLayout.Children.Add(boxView, Constraint.Constant(point.X), Constraint.Constant(point.Y), widthConstraint: Constraint.RelativeToParent((parent) => { return parent.Width; }));
}
|
[XAML]
<sfGrid:SfDataGrid x:Name="dataGrid"
AutoGenerateColumns="False"
HeaderRowHeight="80"
VerticalOverScrollMode="None"
ColumnSizer="Star"
ItemsSource="{Binding OrderInfoCollection}">
<sfGrid:SfDataGrid.Columns>
<sfGrid:GridTemplateColumn MappingName="Customer">
<sfGrid:GridTemplateColumn.CellTemplate>
<DataTemplate>
<border:SfBorder Margin="0" Padding="0" BorderWidth="0">
…….
</border:SfBorder>
</DataTemplate>
</sfGrid:GridTemplateColumn.CellTemplate>
</sfGrid:GridTemplateColumn>
…….
</sfGrid:SfDataGrid.Columns>
</sfGrid:SfDataGrid> |
|