Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
325
XamDataGrid's ScrollToLastRowByIndex doesn't work
posted

int nIndex = 0;
private async void BtnMeasureClick(object sender, EventArgs e)
{
PhotometricMeasureData test = new PhotometricMeasureData();
++nIndex;
test.No = nIndex.ToString();
test.Cell = string.Format("C[{0}]", nIndex);
test.DateTime = DateTime.Now;

for (int i = 0; i < this.m_Model.WaveLength.Count; i++)
{
test.ABS.Add(new Random().Next(-10, 10));
test.Trans.Add(new Random().Next(-10, 10));
}

this.m_Model.MeasureData.Add(test);

int n = this.m_Model.MeasureData.Count;
this.xDataGrid.ScrollToLastRowByIndex(n);
}

public ObservableCollection<PhotometricMeasureData> MeasureData
{
set; get;
} = new ObservableCollection<PhotometricMeasureData>();

public class PhotometricMeasureData
{
public string No { get; set; }
public string Cell { get; set; }
public DateTime DateTime { get; set; }
public List<float> ABS
{
get; set;
} = new List<float>();

public List<float> Trans
{
get; set;
} = new List<float>();
}

Click the button to create and insert virtual data. But it doesn't move to the last line.

Is there any other reason? One strange thing is that you shouldn't put count in the index, but if you set it to int n = 10 it will work.

is this a bug?

Parents Reply
  • 325
    Offline posted in reply to Andrew Goldenbaum

    <ContentPage:ComponentCommon
    x:Class="POP.Component.Photometric.Photometric_Main"
    xmlns="
    ">xamarin.com/.../forms"
    xmlns:x="">schemas.microsoft.com/.../xaml"
    xmlns:ContentPage="clr-namespace:POP.Component"
    xmlns:Ctrl="clr-namespace:POP.Controls"
    xmlns:Local="clr-namespace:KLAB.Localizations.Words;assembly=Localizations"
    xmlns:charts="clr-namespace:Infragistics.XamarinForms.Controls.Charts;assembly=Infragistics.XF.Charts"
    xmlns:igGrid="clr-namespace:Infragistics.XamarinForms.Controls.Grids;assembly=Infragistics.XF.DataGrid"
    BackgroundColor="{StaticResource ColorBack001}">

    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition Height="58" />
    <RowDefinition Height="1*" />
    <RowDefinition Height="60" />
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>


    <!-- 상시 측정 화면 표시 -->
    <ContentView
    x:Name="xRealTimeMeasureComp"
    Grid.Row="0"
    Grid.Column="0"
    HorizontalOptions="FillAndExpand"
    VerticalOptions="FillAndExpand" />


    <Grid
    x:Name="xGrdMainContents"
    Grid.Row="1"
    Grid.Column="0"
    Margin="5,0,5,0"
    ColumnSpacing="0">

    <Grid.ColumnDefinitions>
    <ColumnDefinition x:Name="xGrdMainChart" Width="*" />
    </Grid.ColumnDefinitions>

    <Frame
    Grid.Column="0"
    Padding="1"
    BackgroundColor="{StaticResource ColorBorder000}"
    HasShadow="False">
    <Frame
    Padding="0"
    BackgroundColor="{StaticResource ColorBack002}"
    HasShadow="false">

    <igGrid:XamDataGrid
    x:Name="xDataGrid"
    Margin="5,5,0,0"
    BackgroundColor="{StaticResource ColorBack002}" />

    </Frame>
    </Frame>
    </Grid>


    <!--#region Bottom Buttons (Blank, Measure)-->
    <StackLayout
    x:Name="xSlBotTools"
    Grid.Row="2"
    Grid.Column="0"
    Margin="5,-2,0,5"
    HorizontalOptions="Start"
    Orientation="Horizontal"
    Spacing="10">

    <Ctrl:CtrlOptionButton
    x:Name="m_btnOption"
    Event_OptionButton_Click="BtnOptionMenuClick"
    WidthRequest="60" />
    <Ctrl:CtrlButton
    x:Name="xbtnBlank"
    Clicked="BtnBlankClick"
    Text="Blank"
    WidthRequest="190" />
    <Ctrl:CtrlButton
    x:Name="xbtnMeasure"
    Clicked="BtnMeasureClick"
    Text="Measure"
    WidthRequest="190" />
    </StackLayout>
    <!--#endregion-->


    <!--<StackLayout
    Grid.Row="2"
    Grid.Column="0"
    Margin="0,-2,5,5"
    HorizontalOptions="End"
    Orientation="Horizontal">
    <Ctrl:CtrlButton
    x:Name="xbtnViewChange"
    Clicked="BtnViewChangeClick"
    HorizontalOptions="End"
    Text="View Change"
    WidthRequest="190" />
    </StackLayout>-->
    </Grid>

    </ContentPage:ComponentCommon>

    Please understand that we cannot send sample source code because multiple projects are linked.

    Attach Xaml content. please check once more

Children