问:
UWP Listview to freeze columns in horizontal scrolling
I have a UWP list view with 15+ columns, i wanted to freeze first 2 columns while scrolling horizontally so that user knows which row he's scrolling.
So, Is there any possibility to freeze first 2 columns of a listview item while scrolling horizontally.

Note : I need this without using any Thirdparty controls.

This is the sample code after trying overlapping of two listviews

``` <ScrollViewer  VerticalScrollBarVisibility="Auto" Grid.Row="2" Grid.ColumnSpan="15" MinHeight="300" MaxHeight="450">
                            <Border x:Name="GridBorder1" Grid.Row="2" Grid.Column="0" BorderBrush="LightSlateGray"  Visibility="Visible"   VerticalAlignment="Top"    Grid.ColumnSpan="15" Background="Black" BorderThickness="1" MinHeight="300" MaxHeight="450" Margin="0,2,0,0">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <ListView x:Name="ListView1" ItemsSource="{Binding }" Style="{StaticResource NoScrollListView}">
                                        <ListView.HeaderTemplate>
                                            <DataTemplate>
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="150"></ColumnDefinition>
                                                        <ColumnDefinition Width="280"></ColumnDefinition>
                                                    </Grid.ColumnDefinitions>
                                                    <Button Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" Content="S.No" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" Content="Product Id" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch" Content="Product Desc" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                </Grid>
                                            </DataTemplate>
                                        </ListView.HeaderTemplate>
                                        <ListView.ItemTemplate>
                                            <DataTemplate>
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="150"></ColumnDefinition>
                                                        <ColumnDefinition Width="280"></ColumnDefinition>
                                                    </Grid.ColumnDefinitions>
                                                    <TextBlock Text="{Binding sno,UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Foreground="White" />
                                                    <TextBlock Text="{Binding skuId}" Foreground="White" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Grid.Column="1" HorizontalAlignment="Left"/>
                                                    <TextBlock Text="{Binding itemDesc }" Foreground="White" ToolTipService.ToolTip="{Binding itemDesc}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" Grid.Column="2" HorizontalAlignment="Left"/>

                                                </Grid>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>
                                        <ListView.ItemContainerStyle>

                                        </ListView.ItemContainerStyle>
                                    </ListView>

                                    <ListView x:Name="ListView2"  Grid.ColumnSpan="2" Style="{StaticResource NoScrollListView}" >
                                        <ListView.HeaderTemplate>
                                            <DataTemplate>
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="150"></ColumnDefinition>
                                                        <ColumnDefinition Width="280"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="175"></ColumnDefinition>
                                                        <ColumnDefinition Width="95"></ColumnDefinition>
                                                        <ColumnDefinition Width="105"></ColumnDefinition>
                                                        <ColumnDefinition Width="100"></ColumnDefinition>
                                                        <ColumnDefinition Width="80"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>

                                                        <ColumnDefinition Width="80"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>

                                                        <ColumnDefinition Width="110"></ColumnDefinition>
                                                        <ColumnDefinition Width="110"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>
                                                        <ColumnDefinition Width="40"></ColumnDefinition>
                                                        <ColumnDefinition Width="40"></ColumnDefinition>
                                                    </Grid.ColumnDefinitions>
                                                    <Button Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" Content="S.No" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" Content="Product Id" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch" Content="Product Desc" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="3" HorizontalAlignment="Stretch" Content="UOM" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="4" HorizontalAlignment="Stretch" Content="Product Track Code" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="5" HorizontalAlignment="Stretch" Content="Batch ID" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="6" HorizontalAlignment="Stretch" Content="Exp Date" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="7" HorizontalAlignment="Stretch" Content="HSN Code" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="8" HorizontalAlignment="Stretch" Content="Discount(%)" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="9" HorizontalAlignment="Stretch" Content="Flat Dis" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="10" HorizontalAlignment="Stretch" Content="Tax(%)" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="11"  HorizontalAlignment="Stretch" Content="PO Qty" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="12" HorizontalAlignment="Stretch" Content="PO Price" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="13" HorizontalAlignment="Stretch" Content="Delivery Qty" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Visibility="Collapsed" Grid.Column="14" HorizontalAlignment="Stretch" Content="No of Units" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="14" Content="MRP" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="15" Content="Delivery Price" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="16" Content="Net Cost" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="17" Content="Handled By" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="18" Grid.ColumnSpan="2" Content="Action" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                </Grid>
                                            </DataTemplate>
                                        </ListView.HeaderTemplate>
                                        <ListView.ItemTemplate>
                                            <DataTemplate >
                                                <Grid >
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="150"></ColumnDefinition>
                                                        <ColumnDefinition Width="280"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="175"></ColumnDefinition>
                                                        <ColumnDefinition Width="95"></ColumnDefinition>
                                                        <ColumnDefinition Width="105"></ColumnDefinition>
                                                        <ColumnDefinition Width="100"></ColumnDefinition>
                                                        <ColumnDefinition Width="80"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>

                                                        <ColumnDefinition Width="80"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>

                                                        <ColumnDefinition Width="110"></ColumnDefinition>
                                                        <ColumnDefinition Width="110"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>
                                                        <ColumnDefinition Width="40"></ColumnDefinition>
                                                        <ColumnDefinition Width="40"></ColumnDefinition>
                                                    </Grid.ColumnDefinitions>
                                                    <TextBlock Text="{Binding sno,UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Foreground="White" />
                                                    <TextBlock Text="{Binding skuId}" Foreground="White" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Grid.Column="1" HorizontalAlignment="Left"/>
                                                    <TextBlock Text="{Binding itemDesc }" Foreground="White" ToolTipService.ToolTip="{Binding itemDesc}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" Grid.Column="2" HorizontalAlignment="Left"/>
                                                    <TextBlock Text="{Binding uom}" Foreground="White" ToolTipService.ToolTip="{Binding itemDesc}" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                                    <TextBox Text="{Binding itemScanCode,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}"  TabIndex="4" Margin="2" MaxLength="20"  Foreground="Black" Grid.Row="0" Grid.Column="4" BorderBrush="White" BorderThickness="1" Name="txtEAN" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" LostFocus="txtEAN_LostFocus" KeyDown="txtEAN_KeyDown" ></TextBox>
                                                    <TextBox Text="{Binding bactchNum , UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}"  TabIndex="5" MaxLength="20" Margin="2" Foreground="Black" Grid.Row="0" Grid.Column="5" BorderBrush="White" BorderThickness="1" Name="txtBatch" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" LostFocus="txtBatch_LostFocus" KeyDown="txtBatch_KeyDown" ></TextBox>

                                                    <TextBox Text="{Binding expiry_date,UpdateSourceTrigger=PropertyChanged}"  ToolTipService.ToolTip="{Binding itemDesc}"  TabIndex="6" MaxLength="20" Margin="2" FontSize="14" Foreground="Black" Grid.Row="0" Grid.Column="6" BorderBrush="White" BorderThickness="1" Name="txtEXPDate" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" LostFocus="txtEXPDate_LostFocus" PlaceholderText="dd/mm/yyyy" KeyDown="TxtEXPDate_KeyDown" ></TextBox>
                                                    <TextBox Text="{Binding hsnCode,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}"  TabIndex="7" MaxLength="20" Margin="2" FontSize="14" Foreground="Black" Grid.Row="0" Grid.Column="7" BorderBrush="White" BorderThickness="1" Name="txtHsnCode" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" PlaceholderText="HSN Code" LostFocus="TxtHsnCode_LostFocus" KeyUp="txtAutoBox_KeyUp" ></TextBox>
                                                    <TextBox TabIndex="8"  MaxLength="20" Margin="1" FontSize="14" ToolTipService.ToolTip="{Binding itemDesc}" Foreground="Black" Grid.Row="0"  Grid.Column="8" BorderBrush="White" BorderThickness="1" PlaceholderText="(%)Discount" Name="txtperDiscount" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource TextBoxstyles}" TextChanging="txtAutoDeliveryQty_TextChanging" TextChanged="TxtperDiscount_TextChanged" KeyDown="TxtperDiscount_KeyDown" GotFocus="TxtperDiscount_GotFocus" ></TextBox>
                                                    <TextBox  TabIndex="9" MaxLength="20" Margin="1" FontSize="14" Foreground="Black" Grid.Row="0" ToolTipService.ToolTip="{Binding itemDesc}" Grid.Column="9" BorderBrush="White" BorderThickness="1" Name="txtFlatDicount" PlaceholderText="Flat Discount" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" TextChanging="txtAutoDeliveryQty_TextChanging" TextChanged="TxtFlatDicount_TextChanged" GotFocus="TxtFlatDicount_GotFocus" KeyDown="TxtFlatDicount_KeyDown"   ></TextBox>

                                                    <TextBox Text="{Binding taxRate,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}" TextAlignment="Center" Style="{StaticResource TextBoxstyles}" Margin="2" TabIndex="10"  FontSize="13" Foreground="Black" Grid.Row="0" Grid.Column="10" BorderBrush="White" BorderThickness="1" Background="White"   Name="txtAutoTax"  VerticalAlignment="Center" HorizontalAlignment="Center"  LostFocus="txtAutoTax_LostFocus" TextChanging="txtAutoTax_TextChanging"  KeyUp="txtAutoBox_KeyUp" ></TextBox>
                                                    <TextBlock Text="{Binding orderQty,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}" Foreground="White" Grid.Column="11" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                                    <TextBlock Text="{Binding orderPrice,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}" Foreground="White" Grid.Column="12" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                                    <TextBox Visibility="Collapsed"   MaxLength="20" Margin="2" FontSize="14" ToolTipService.ToolTip="{Binding itemDesc}" Foreground="Black" Grid.Row="0" Grid.Column="13" BorderBrush="White" BorderThickness="1" Name="txtFreeqty" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}"  ></TextBox>
                                                    <TextBox  TextAlignment="Center" Style="{StaticResource TextBoxstyles}" ToolTipService.ToolTip="{Binding itemDesc}" Text="{Binding suppliedQty,UpdateSourceTrigger=PropertyChanged}" Margin="0,2,0,3"  FontSize="14" Foreground="Black"  Grid.Row="0" Grid.Column="13" BorderBrush="White" BorderThickness="1" Background="White" IsEnabled="{Binding qtyEditable}"  Name="txtAutoDeliveryQty"  TextChanging="txtAutoDeliveryQty_TextChanging" Loaded="txtAutoDeliveryQty_Loaded" VerticalAlignment="Center" LostFocus="txtAutoDeliveryQty_LostFocus" KeyDown="TxtAutoDeliveryQty_KeyDown" GotFocus="TxtAutoDeliveryQty_GotFocus"  TabIndex="0" >

                                                    </TextBox>

                                                    <TextBox Visibility="Collapsed" ToolTipService.ToolTip="{Binding itemDesc}"  Text="{Binding pack_size}"   MaxLength="20" Margin="2" FontSize="14" Foreground="Black" Grid.Row="0" Grid.Column="14" BorderBrush="White" BorderThickness="1" Name="txtnoofUnit" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}"  ></TextBox>
                                                    <TextBox Text="{Binding mrp,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}"  TabIndex="1" MaxLength="20" Margin="2" FontSize="14" Foreground="Black" Grid.Row="0" Grid.Column="14" BorderBrush="White" BorderThickness="1" Name="txtMRP" Background="White" TextAlignment="Center" LostFocus="TxtMRP_LostFocus"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" KeyUp="txtAutoBox_KeyUp"  ></TextBox>

                                                    <TextBox Loaded="txtAutoDeliveryCost_Loaded"  TextAlignment="Center" ToolTipService.ToolTip="{Binding itemDesc}" Text="{Binding supplyPrice,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxstyles}" Margin="0,2,0,3" FontSize="14" x:Name="txtAutoDeliveryCost" Foreground="Black" Grid.Row="0" Grid.Column="15" BorderBrush="White" IsEnabled="{Binding costpriceEditable}" BorderThickness="1" Background="White"  VerticalAlignment="Center" TextChanging="txtAutoDeliveryCost_TextChanging"   LostFocus="txtAutoDeliveryCost_LostFocus" KeyUp="txtAutoBox_KeyUp" TabIndex="2"></TextBox>
                                                    <TextBlock Text="{Binding totalCost,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}" Foreground="White"  Grid.Column="16" VerticalAlignment="Center"  HorizontalAlignment="Center" />
                                                    <ComboBox TabIndex="3" PlaceholderText="Handled By"  Grid.Row="0" Grid.Column="17"  Margin="0,3,0,0"  Name="comboHandeledBy" ItemsSource="{Binding objEmployeeName}"  SelectedItem="{Binding Path=handledBy}"  VerticalAlignment="Center" Style="{StaticResource   newGrnComboStyle}" SelectionChanged="comboHandeledBy_SelectionChanged" >
                                                        <ComboBox.ItemTemplate>
                                                            <DataTemplate>
                                                                <StackPanel Orientation="Horizontal"  Width="Auto" Height="Auto">
                                                                    <TextBlock Name="txtEmployeeName">
                                                                     <Run Text="{Binding handledBy}"></Run>
                                                                    </TextBlock>
                                                                </StackPanel>
                                                            </DataTemplate>
                                                        </ComboBox.ItemTemplate>
                                                    </ComboBox>
                                                    <StackPanel ToolTipService.ToolTip="{Binding itemDesc}" Orientation="Horizontal" Margin="0.5,0,0,0" Grid.Column="18">
                                                        <Button  Grid.Row="0" Width="auto"   VerticalAlignment="Center" HorizontalAlignment="Center" Background="Black" BorderBrush="Black" BorderThickness="0" x:Name="btnDelete" Tapped="btnDelete_Tapped">
                                                            <Image Source="/Images/delete.png" Width="27" Height="20"></Image>
                                                        </Button>
                                                    </StackPanel>
                                                    <StackPanel Orientation="Horizontal" Margin="0.5,0,0,0" Grid.Column="19">
                                                        <Button  Grid.Row="0" Width="auto"   VerticalAlignment="Center" HorizontalAlignment="Center" Background="Black" BorderBrush="Black" Visibility="{Binding isVisible}" BorderThickness="0" x:Name="btnAdd" Tapped="btnAdd_Tapped">
                                                            <Image Source="/Images/plus_sign.png" Width="27" Height="18"></Image>
                                                        </Button>
                                                    </StackPanel>
                                                </Grid>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>

                                        <ListView.ItemContainerStyle>

                                        </ListView.ItemContainerStyle>

                                    </ListView>

                                </Grid>
                            </Border>
                        </ScrollViewer>
```

答:
UWP native ListView does not provide the option to freeze a column. In fact, the column should be defined by you in the DataTemplate.

If you want to use ListView to achieve your needs, this may require two ListView to display side by side.

This is a piece of code used to show ideas and does not contain real content

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <ListView x:Name="FreezeListView"
              ItemTemplate="{StaticResource FreezeRowTemplate}"
              ItemsSource="{x:Bind FreezeCollection}"
              />
    <ListView x:Name="DefaultListView"
              Grid.Column="1"
              ItemTemplate="{StaticResource DefaultRowTemplate}"
              ItemsSource="{x:Bind DefaultCollection}"
              />
</Grid>
```

<p>By extracting the frozen column data and displaying it separately, the scrolling of the <code>DefaultListView</code> will not affect the <code>FreezeListView</code>.</p>

<hr>

<p>From your description, the DataGrid control is also provided in UWP, which contains the properties of the frozen column. The control comes from the <code>WindowsCommunityToolkit</code>. This tool set is maintained by Microsoft. It is a supplement to the native control and is open source.</p>

<p>This is the relevant content of <code>DataGrid</code>, if necessary, you can view:</p>

<ul>
<li>DataGrid</li>
<li>Source code</li>
</ul>

<hr>

<p><strong>Update</strong></p>

<p>There is a <code>ScrollViewer</code> inside the <code>ListView</code>, and the scrolling of the two <code>ListView</code>s is independent of each other and does not affect each other. If you want to scroll synchronously, then one idea is to put two <code>ListView</code> in the same <code>ScrollViewer</code> control, and in order not to completely invalidate the virtualization of <code>ListView</code>, we need to modify the <code>ListView</code> control template</p>

<pre class="lang-xml prettyprint-override"><code><Page.Resources>
    <Style x:Key="NoScrollListView" TargetType="ListView">
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="TabNavigation" Value="Once"/>
        <Setter Property="IsSwipeEnabled" Value="True"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto"/>
        <Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="False"/>
        <Setter Property="ScrollViewer.VerticalScrollMode" Value="Enabled"/>
        <Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="True"/>
        <Setter Property="ScrollViewer.ZoomMode" Value="Disabled"/>
        <Setter Property="ShowsScrollingPlaceholders" Value="True" />
        <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False"/>
        <Setter Property="ScrollViewer.BringIntoViewOnFocusChange" Value="True"/>
        <Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}"/>
        <Setter Property="ItemContainerTransitions">
            <Setter.Value>
                <TransitionCollection>
                    <AddDeleteThemeTransition/>
                    <ContentThemeTransition/>
                    <ReorderThemeTransition/>
                    <EntranceThemeTransition IsStaggeringEnabled="False"/>
                </TransitionCollection>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <ItemsStackPanel Orientation="Vertical"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListView">
                    <ItemsPresenter Footer="{TemplateBinding Footer}" FooterTransitions="{TemplateBinding FooterTransitions}" FooterTemplate="{TemplateBinding FooterTemplate}" Header="{TemplateBinding Header}" HeaderTransitions="{TemplateBinding HeaderTransitions}" HeaderTemplate="{TemplateBinding HeaderTemplate}" Padding="{TemplateBinding Padding}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Page.Resources>
</code>```

Usage

<ScrollViewer>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ListView x:Name="ListView1" Style="{StaticResource NoScrollListView}"/>
        <ListView x:Name="ListView2" Grid.Column="1" Style="{StaticResource NoScrollListView}"/>
    </Grid>
</ScrollViewer>
```

Body:
I have a UWP list view with 15+ columns, i wanted to freeze first 2 columns while scrolling horizontally so that user knows which row he's scrolling.
So, Is there any possibility to freeze first 2 columns of a listview item while scrolling horizontally.

Note : I need this without using any Thirdparty controls.

This is the sample code after trying overlapping of two listviews

 <ScrollViewer  VerticalScrollBarVisibility="Auto" Grid.Row="2" Grid.ColumnSpan="15" MinHeight="300" MaxHeight="450">
                            <Border x:Name="GridBorder1" Grid.Row="2" Grid.Column="0" BorderBrush="LightSlateGray"  Visibility="Visible"   VerticalAlignment="Top"    Grid.ColumnSpan="15" Background="Black" BorderThickness="1" MinHeight="300" MaxHeight="450" Margin="0,2,0,0">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <ListView x:Name="ListView1" ItemsSource="{Binding }" Style="{StaticResource NoScrollListView}">
                                        <ListView.HeaderTemplate>
                                            <DataTemplate>
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="150"></ColumnDefinition>
                                                        <ColumnDefinition Width="280"></ColumnDefinition>
                                                    </Grid.ColumnDefinitions>
                                                    <Button Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" Content="S.No" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" Content="Product Id" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch" Content="Product Desc" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                </Grid>
                                            </DataTemplate>
                                        </ListView.HeaderTemplate>
                                        <ListView.ItemTemplate>
                                            <DataTemplate>
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="150"></ColumnDefinition>
                                                        <ColumnDefinition Width="280"></ColumnDefinition>
                                                    </Grid.ColumnDefinitions>
                                                    <TextBlock Text="{Binding sno,UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Foreground="White" />
                                                    <TextBlock Text="{Binding skuId}" Foreground="White" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Grid.Column="1" HorizontalAlignment="Left"/>
                                                    <TextBlock Text="{Binding itemDesc }" Foreground="White" ToolTipService.ToolTip="{Binding itemDesc}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" Grid.Column="2" HorizontalAlignment="Left"/>

                                                </Grid>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>
                                        <ListView.ItemContainerStyle>

                                        </ListView.ItemContainerStyle>
                                    </ListView>

                                    <ListView x:Name="ListView2"  Grid.ColumnSpan="2" Style="{StaticResource NoScrollListView}" >
                                        <ListView.HeaderTemplate>
                                            <DataTemplate>
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="150"></ColumnDefinition>
                                                        <ColumnDefinition Width="280"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="175"></ColumnDefinition>
                                                        <ColumnDefinition Width="95"></ColumnDefinition>
                                                        <ColumnDefinition Width="105"></ColumnDefinition>
                                                        <ColumnDefinition Width="100"></ColumnDefinition>
                                                        <ColumnDefinition Width="80"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>

                                                        <ColumnDefinition Width="80"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>

                                                        <ColumnDefinition Width="110"></ColumnDefinition>
                                                        <ColumnDefinition Width="110"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>
                                                        <ColumnDefinition Width="40"></ColumnDefinition>
                                                        <ColumnDefinition Width="40"></ColumnDefinition>
                                                    </Grid.ColumnDefinitions>
                                                    <Button Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" Content="S.No" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" Content="Product Id" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch" Content="Product Desc" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="3" HorizontalAlignment="Stretch" Content="UOM" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="4" HorizontalAlignment="Stretch" Content="Product Track Code" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="5" HorizontalAlignment="Stretch" Content="Batch ID" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="6" HorizontalAlignment="Stretch" Content="Exp Date" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="7" HorizontalAlignment="Stretch" Content="HSN Code" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="8" HorizontalAlignment="Stretch" Content="Discount(%)" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="9" HorizontalAlignment="Stretch" Content="Flat Dis" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="10" HorizontalAlignment="Stretch" Content="Tax(%)" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="11"  HorizontalAlignment="Stretch" Content="PO Qty" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="12" HorizontalAlignment="Stretch" Content="PO Price" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="13" HorizontalAlignment="Stretch" Content="Delivery Qty" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Visibility="Collapsed" Grid.Column="14" HorizontalAlignment="Stretch" Content="No of Units" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="14" Content="MRP" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="15" Content="Delivery Price" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                    <Button Grid.Row="1" Grid.Column="16" Content="Net Cost" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="17" Content="Handled By" Style="{StaticResource newGrnButtonStyle2}"></Button>
                                                    <Button Grid.Row="1" Grid.Column="18" Grid.ColumnSpan="2" Content="Action" Style="{StaticResource newGrnButtonStyle2}"></Button>

                                                </Grid>
                                            </DataTemplate>
                                        </ListView.HeaderTemplate>
                                        <ListView.ItemTemplate>
                                            <DataTemplate >
                                                <Grid >
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="150"></ColumnDefinition>
                                                        <ColumnDefinition Width="280"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="175"></ColumnDefinition>
                                                        <ColumnDefinition Width="95"></ColumnDefinition>
                                                        <ColumnDefinition Width="105"></ColumnDefinition>
                                                        <ColumnDefinition Width="100"></ColumnDefinition>
                                                        <ColumnDefinition Width="80"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="70"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>

                                                        <ColumnDefinition Width="80"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>

                                                        <ColumnDefinition Width="110"></ColumnDefinition>
                                                        <ColumnDefinition Width="110"></ColumnDefinition>
                                                        <ColumnDefinition Width="90"></ColumnDefinition>
                                                        <ColumnDefinition Width="40"></ColumnDefinition>
                                                        <ColumnDefinition Width="40"></ColumnDefinition>
                                                    </Grid.ColumnDefinitions>
                                                    <TextBlock Text="{Binding sno,UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Foreground="White" />
                                                    <TextBlock Text="{Binding skuId}" Foreground="White" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Grid.Column="1" HorizontalAlignment="Left"/>
                                                    <TextBlock Text="{Binding itemDesc }" Foreground="White" ToolTipService.ToolTip="{Binding itemDesc}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" Grid.Column="2" HorizontalAlignment="Left"/>
                                                    <TextBlock Text="{Binding uom}" Foreground="White" ToolTipService.ToolTip="{Binding itemDesc}" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                                    <TextBox Text="{Binding itemScanCode,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}"  TabIndex="4" Margin="2" MaxLength="20"  Foreground="Black" Grid.Row="0" Grid.Column="4" BorderBrush="White" BorderThickness="1" Name="txtEAN" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" LostFocus="txtEAN_LostFocus" KeyDown="txtEAN_KeyDown" ></TextBox>
                                                    <TextBox Text="{Binding bactchNum , UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}"  TabIndex="5" MaxLength="20" Margin="2" Foreground="Black" Grid.Row="0" Grid.Column="5" BorderBrush="White" BorderThickness="1" Name="txtBatch" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" LostFocus="txtBatch_LostFocus" KeyDown="txtBatch_KeyDown" ></TextBox>

                                                    <TextBox Text="{Binding expiry_date,UpdateSourceTrigger=PropertyChanged}"  ToolTipService.ToolTip="{Binding itemDesc}"  TabIndex="6" MaxLength="20" Margin="2" FontSize="14" Foreground="Black" Grid.Row="0" Grid.Column="6" BorderBrush="White" BorderThickness="1" Name="txtEXPDate" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" LostFocus="txtEXPDate_LostFocus" PlaceholderText="dd/mm/yyyy" KeyDown="TxtEXPDate_KeyDown" ></TextBox>
                                                    <TextBox Text="{Binding hsnCode,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}"  TabIndex="7" MaxLength="20" Margin="2" FontSize="14" Foreground="Black" Grid.Row="0" Grid.Column="7" BorderBrush="White" BorderThickness="1" Name="txtHsnCode" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" PlaceholderText="HSN Code" LostFocus="TxtHsnCode_LostFocus" KeyUp="txtAutoBox_KeyUp" ></TextBox>
                                                    <TextBox TabIndex="8"  MaxLength="20" Margin="1" FontSize="14" ToolTipService.ToolTip="{Binding itemDesc}" Foreground="Black" Grid.Row="0"  Grid.Column="8" BorderBrush="White" BorderThickness="1" PlaceholderText="(%)Discount" Name="txtperDiscount" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource TextBoxstyles}" TextChanging="txtAutoDeliveryQty_TextChanging" TextChanged="TxtperDiscount_TextChanged" KeyDown="TxtperDiscount_KeyDown" GotFocus="TxtperDiscount_GotFocus" ></TextBox>
                                                    <TextBox  TabIndex="9" MaxLength="20" Margin="1" FontSize="14" Foreground="Black" Grid.Row="0" ToolTipService.ToolTip="{Binding itemDesc}" Grid.Column="9" BorderBrush="White" BorderThickness="1" Name="txtFlatDicount" PlaceholderText="Flat Discount" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" TextChanging="txtAutoDeliveryQty_TextChanging" TextChanged="TxtFlatDicount_TextChanged" GotFocus="TxtFlatDicount_GotFocus" KeyDown="TxtFlatDicount_KeyDown"   ></TextBox>

                                                    <TextBox Text="{Binding taxRate,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}" TextAlignment="Center" Style="{StaticResource TextBoxstyles}" Margin="2" TabIndex="10"  FontSize="13" Foreground="Black" Grid.Row="0" Grid.Column="10" BorderBrush="White" BorderThickness="1" Background="White"   Name="txtAutoTax"  VerticalAlignment="Center" HorizontalAlignment="Center"  LostFocus="txtAutoTax_LostFocus" TextChanging="txtAutoTax_TextChanging"  KeyUp="txtAutoBox_KeyUp" ></TextBox>
                                                    <TextBlock Text="{Binding orderQty,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}" Foreground="White" Grid.Column="11" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                                    <TextBlock Text="{Binding orderPrice,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}" Foreground="White" Grid.Column="12" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                                    <TextBox Visibility="Collapsed"   MaxLength="20" Margin="2" FontSize="14" ToolTipService.ToolTip="{Binding itemDesc}" Foreground="Black" Grid.Row="0" Grid.Column="13" BorderBrush="White" BorderThickness="1" Name="txtFreeqty" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}"  ></TextBox>
                                                    <TextBox  TextAlignment="Center" Style="{StaticResource TextBoxstyles}" ToolTipService.ToolTip="{Binding itemDesc}" Text="{Binding suppliedQty,UpdateSourceTrigger=PropertyChanged}" Margin="0,2,0,3"  FontSize="14" Foreground="Black"  Grid.Row="0" Grid.Column="13" BorderBrush="White" BorderThickness="1" Background="White" IsEnabled="{Binding qtyEditable}"  Name="txtAutoDeliveryQty"  TextChanging="txtAutoDeliveryQty_TextChanging" Loaded="txtAutoDeliveryQty_Loaded" VerticalAlignment="Center" LostFocus="txtAutoDeliveryQty_LostFocus" KeyDown="TxtAutoDeliveryQty_KeyDown" GotFocus="TxtAutoDeliveryQty_GotFocus"  TabIndex="0" >

                                                    </TextBox>

                                                    <TextBox Visibility="Collapsed" ToolTipService.ToolTip="{Binding itemDesc}"  Text="{Binding pack_size}"   MaxLength="20" Margin="2" FontSize="14" Foreground="Black" Grid.Row="0" Grid.Column="14" BorderBrush="White" BorderThickness="1" Name="txtnoofUnit" Background="White" TextAlignment="Center"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}"  ></TextBox>
                                                    <TextBox Text="{Binding mrp,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}"  TabIndex="1" MaxLength="20" Margin="2" FontSize="14" Foreground="Black" Grid.Row="0" Grid.Column="14" BorderBrush="White" BorderThickness="1" Name="txtMRP" Background="White" TextAlignment="Center" LostFocus="TxtMRP_LostFocus"  VerticalAlignment="Center" Style="{StaticResource  TextBoxstyles}" KeyUp="txtAutoBox_KeyUp"  ></TextBox>

                                                    <TextBox Loaded="txtAutoDeliveryCost_Loaded"  TextAlignment="Center" ToolTipService.ToolTip="{Binding itemDesc}" Text="{Binding supplyPrice,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxstyles}" Margin="0,2,0,3" FontSize="14" x:Name="txtAutoDeliveryCost" Foreground="Black" Grid.Row="0" Grid.Column="15" BorderBrush="White" IsEnabled="{Binding costpriceEditable}" BorderThickness="1" Background="White"  VerticalAlignment="Center" TextChanging="txtAutoDeliveryCost_TextChanging"   LostFocus="txtAutoDeliveryCost_LostFocus" KeyUp="txtAutoBox_KeyUp" TabIndex="2"></TextBox>
                                                    <TextBlock Text="{Binding totalCost,UpdateSourceTrigger=PropertyChanged}" ToolTipService.ToolTip="{Binding itemDesc}" Foreground="White"  Grid.Column="16" VerticalAlignment="Center"  HorizontalAlignment="Center" />
                                                    <ComboBox TabIndex="3" PlaceholderText="Handled By"  Grid.Row="0" Grid.Column="17"  Margin="0,3,0,0"  Name="comboHandeledBy" ItemsSource="{Binding objEmployeeName}"  SelectedItem="{Binding Path=handledBy}"  VerticalAlignment="Center" Style="{StaticResource   newGrnComboStyle}" SelectionChanged="comboHandeledBy_SelectionChanged" >
                                                        <ComboBox.ItemTemplate>
                                                            <DataTemplate>
                                                                <StackPanel Orientation="Horizontal"  Width="Auto" Height="Auto">
                                                                    <TextBlock Name="txtEmployeeName">
                                                                     <Run Text="{Binding handledBy}"></Run>
                                                                    </TextBlock>
                                                                </StackPanel>
                                                            </DataTemplate>
                                                        </ComboBox.ItemTemplate>
                                                    </ComboBox>
                                                    <StackPanel ToolTipService.ToolTip="{Binding itemDesc}" Orientation="Horizontal" Margin="0.5,0,0,0" Grid.Column="18">
                                                        <Button  Grid.Row="0" Width="auto"   VerticalAlignment="Center" HorizontalAlignment="Center" Background="Black" BorderBrush="Black" BorderThickness="0" x:Name="btnDelete" Tapped="btnDelete_Tapped">
                                                            <Image Source="/Images/delete.png" Width="27" Height="20"></Image>
                                                        </Button>
                                                    </StackPanel>
                                                    <StackPanel Orientation="Horizontal" Margin="0.5,0,0,0" Grid.Column="19">
                                                        <Button  Grid.Row="0" Width="auto"   VerticalAlignment="Center" HorizontalAlignment="Center" Background="Black" BorderBrush="Black" Visibility="{Binding isVisible}" BorderThickness="0" x:Name="btnAdd" Tapped="btnAdd_Tapped">
                                                            <Image Source="/Images/plus_sign.png" Width="27" Height="18"></Image>
                                                        </Button>
                                                    </StackPanel>
                                                </Grid>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>

                                        <ListView.ItemContainerStyle>

                                        </ListView.ItemContainerStyle>

                                    </ListView>

                                </Grid>
                            </Border>
                        </ScrollViewer>

Body:
UWP native ListView does not provide the option to freeze a column. In fact, the column should be defined by you in the DataTemplate.

If you want to use ListView to achieve your needs, this may require two ListView to display side by side.

This is a piece of code used to show ideas and does not contain real content

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <ListView x:Name="FreezeListView"
              ItemTemplate="{StaticResource FreezeRowTemplate}"
              ItemsSource="{x:Bind FreezeCollection}"
              />
    <ListView x:Name="DefaultListView"
              Grid.Column="1"
              ItemTemplate="{StaticResource DefaultRowTemplate}"
              ItemsSource="{x:Bind DefaultCollection}"
              />
</Grid>

By extracting the frozen column data and displaying it separately, the scrolling of the DefaultListView will not affect the FreezeListView.

From your description, the DataGrid control is also provided in UWP, which contains the properties of the frozen column. The control comes from the WindowsCommunityToolkit. This tool set is maintained by Microsoft. It is a supplement to the native control and is open source.

This is the relevant content of DataGrid, if necessary, you can view:

DataGrid

Source code

Update

There is a ScrollViewer inside the ListView, and the scrolling of the two ListViews is independent of each other and does not affect each other. If you want to scroll synchronously, then one idea is to put two ListView in the same ScrollViewer control, and in order not to completely invalidate the virtualization of ListView, we need to modify the ListView control template

<Page.Resources>
    <Style x:Key="NoScrollListView" TargetType="ListView">
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="TabNavigation" Value="Once"/>
        <Setter Property="IsSwipeEnabled" Value="True"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto"/>
        <Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="False"/>
        <Setter Property="ScrollViewer.VerticalScrollMode" Value="Enabled"/>
        <Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="True"/>
        <Setter Property="ScrollViewer.ZoomMode" Value="Disabled"/>
        <Setter Property="ShowsScrollingPlaceholders" Value="True" />
        <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False"/>
        <Setter Property="ScrollViewer.BringIntoViewOnFocusChange" Value="True"/>
        <Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}"/>
        <Setter Property="ItemContainerTransitions">
            <Setter.Value>
                <TransitionCollection>
                    <AddDeleteThemeTransition/>
                    <ContentThemeTransition/>
                    <ReorderThemeTransition/>
                    <EntranceThemeTransition IsStaggeringEnabled="False"/>
                </TransitionCollection>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <ItemsStackPanel Orientation="Vertical"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListView">
                    <ItemsPresenter Footer="{TemplateBinding Footer}" FooterTransitions="{TemplateBinding FooterTransitions}" FooterTemplate="{TemplateBinding FooterTemplate}" Header="{TemplateBinding Header}" HeaderTransitions="{TemplateBinding HeaderTransitions}" HeaderTemplate="{TemplateBinding HeaderTemplate}" Padding="{TemplateBinding Padding}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Page.Resources>

Usage

<ScrollViewer>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ListView x:Name="ListView1" Style="{StaticResource NoScrollListView}"/>
        <ListView x:Name="ListView2" Grid.Column="1" Style="{StaticResource NoScrollListView}"/>
    </Grid>
</ScrollViewer>


来源: stackexchange

问:
BitBlt Memory leak
I am using BitBlt to display Bitmaps on my buttons. For most of it, it is fine, but there is a memory leak which causes the program to crash after a while. What am I doing wrong with this ?</p>

```<code>int Springboard::DrawBasicButtons(DRAWITEMSTRUCT* pdis, HINSTANCE hInstance){
    RECT rect;
    static HBITMAP hCurrIcon, hIconoff, hIconon;
    rect = pdis->rcItem;

    HFONT font = CreateFont(13, 0, 0, 0, 300, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, L"Arial");
    TCHAR Txtstr[MAX_PATH];
    BOOL isText = FALSE;
    int textsize;

    if (IDC_HOLD == pdis->CtlID) {
        hIconoff = (HBITMAP) LoadBitmap(hInstance, MAKEINTRESOURCE(BASIC_HOLDOFF));
        hIconon = (HBITMAP) LoadBitmap(hInstance, MAKEINTRESOURCE(BASIC_HOLDON));
        _tcscpy( Txtstr, _T("Hold      "));
        isText = TRUE;
        if (pdis->itemState & ODS_SELECTED) hCurrIcon = hIconon;
        else hCurrIcon = hIconoff;
    }

    HDC hdc = CreateCompatibleDC(pdis->hDC);
    SelectObject(hdc, hCurrIcon);

    BitBlt(pdis->hDC,0, 0,ICON_WIDTH,ICON_HEIGHT, hdc, 0, 0, SRCCOPY);

    if(isText == TRUE){
        textsize = _tcslen(Txtstr);
        SetTextColor(pdis->hDC, RGB(230,230,230));
        HFONT hFontOld = (HFONT) SelectObject(pdis->hDC, font);
        DrawText(pdis->hDC, Txtstr, textsize, &pdis->rcItem, DT_SINGLELINE | DT_VCENTER | DT_RIGHT);
        SelectObject( pdis->hDC, hFontOld );
    }

    DeleteDC(hdc);
    DeleteBitmap(hCurrIcon);
    DeleteBitmap(hIconoff);
    DeleteBitmap(hIconon);
    font = NULL;

    return(RET_OK);
}
</code>```

答:
try this:

move hiconoff = ... and hiconon = ... outside and above the if statement. They will be deleted any way at the end of function. You can figure out optimization after the bugs are fixed.

At first run hiconon and hiconoff are not set to anything. Don't assume they are null just because they are static data.

ContentLicense: CC BY-SA 3.0

Title: BitBlt Memory leak

Body:
I am using BitBlt to display Bitmaps on my buttons. For most of it, it is fine, but there is a memory leak which causes the program to crash after a while. What am I doing wrong with this ?

int Springboard::DrawBasicButtons(DRAWITEMSTRUCT* pdis, HINSTANCE hInstance){
    RECT rect;
    static HBITMAP hCurrIcon, hIconoff, hIconon;
    rect = pdis->rcItem;

    HFONT font = CreateFont(13, 0, 0, 0, 300, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, L"Arial");
    TCHAR Txtstr[MAX_PATH];
    BOOL isText = FALSE;
    int textsize;

    if (IDC_HOLD == pdis->CtlID) {
        hIconoff = (HBITMAP) LoadBitmap(hInstance, MAKEINTRESOURCE(BASIC_HOLDOFF));
        hIconon = (HBITMAP) LoadBitmap(hInstance, MAKEINTRESOURCE(BASIC_HOLDON));
        _tcscpy( Txtstr, _T("Hold      "));
        isText = TRUE;
        if (pdis->itemState & ODS_SELECTED) hCurrIcon = hIconon;
        else hCurrIcon = hIconoff;
    }

    HDC hdc = CreateCompatibleDC(pdis->hDC);
    SelectObject(hdc, hCurrIcon);

    BitBlt(pdis->hDC,0, 0,ICON_WIDTH,ICON_HEIGHT, hdc, 0, 0, SRCCOPY);

    if(isText == TRUE){
        textsize = _tcslen(Txtstr);
        SetTextColor(pdis->hDC, RGB(230,230,230));
        HFONT hFontOld = (HFONT) SelectObject(pdis->hDC, font);
        DrawText(pdis->hDC, Txtstr, textsize, &pdis->rcItem, DT_SINGLELINE | DT_VCENTER | DT_RIGHT);
        SelectObject( pdis->hDC, hFontOld );
    }

    DeleteDC(hdc);
    DeleteBitmap(hCurrIcon);
    DeleteBitmap(hIconoff);
    DeleteBitmap(hIconon);
    font = NULL;

    return(RET_OK);
}

ContentLicense: CC BY-SA 4.0


问:
Can't get Tornado webserver to thread code
Just getting started with Tornado, have no idea what I'm getting wrong but I can't get it to thread at all, here's the code I'm testing with.

```<code>    import tornado.ioloop
    import tornado.web
    import time
    from threading import Timer

    class MainHandler(tornado.web.RequestHandler):
        @tornado.web.asynchronous
        def get(self):
            t = Timer(5.0, self.on_response)
            t.start()
            print 'thread started'

        def on_response(self):
            self.write(str(time.time()))
            self.finish()

    application = tornado.web.Application([
        (r"/", MainHandler),
    ])

    if __name__ == "__main__":
        application.listen(8888)
        tornado.ioloop.IOLoop.instance().start()
</code>```

If I run this, it works, but it blocks the entire webserver for 5 seconds, so if I try to load this page twice in quick succession, it will print 'thread started', wait 5 seconds, the first browser will load, then it will print 'thread started' again, wait another 5 seconds, and then send the second browser the page, thus taking a total of 10 seconds.

Even running the non-blocking example from the tornado website, I run into this issue. Any ideas?

Tried with python 2.6 and 2.7, Tornado 1.2.1 from easy_install.

答:
The code you posted works as expected for me, with Python 2.6.1 on Snow Leopard. Have you tried testing with curl?:</p>

```<code>curl --no-buffer localhost:8888 & curl --no-buffer localhost:8888
</code>```

Body:
Just getting started with Tornado, have no idea what I'm getting wrong but I can't get it to thread at all, here's the code I'm testing with.

    import tornado.ioloop
    import tornado.web
    import time
    from threading import Timer

    class MainHandler(tornado.web.RequestHandler):
        @tornado.web.asynchronous
        def get(self):
            t = Timer(5.0, self.on_response)
            t.start()
            print 'thread started'

        def on_response(self):
            self.write(str(time.time()))
            self.finish()

    application = tornado.web.Application([
        (r"/", MainHandler),
    ])

    if __name__ == "__main__":
        application.listen(8888)
        tornado.ioloop.IOLoop.instance().start()

If I run this, it works, but it blocks the entire webserver for 5 seconds, so if I try to load this page twice in quick succession, it will print 'thread started', wait 5 seconds, the first browser will load, then it will print 'thread started' again, wait another 5 seconds, and then send the second browser the page, thus taking a total of 10 seconds.

Even running the non-blocking example from the tornado website, I run into this issue. Any ideas?

Tried with python 2.6 and 2.7, Tornado 1.2.1 from easy_install.

Body:
The code you posted works as expected for me, with Python 2.6.1 on Snow Leopard. Have you tried testing with curl?:

curl --no-buffer localhost:8888 & curl --no-buffer localhost:8888


问:
Trie Implementation in Python -- Print Keys
I Implemented a Trie data structure using python, now the problem is it doesn't display the keys that Trie is stored in its data structure.</p>

```<code>class Node:
    def __init__(self):
        self.children = [None] * 26
        self.endOfTheWord = False

class Trie:
    def __init__(self):
        self.root = self.getNode()

    def getNode(self):
        return Node()

    def charToIndex(self ,ch):
        return ord(ch) - ord('a')

    def insert(self ,word):
        current = self.root
        for i in range(len(word)):
            index = self.charToIndex(word[i])

            if current.children[index] is None:
                current.children[index] = self.getNode()

            current = current.children[index]

        current.endOfTheWord = True

    def printKeys(self):
        str = []
        self.printKeysUtil(self.root ,str)

    def printKeysUtil(self ,root ,str):

        if root.endOfTheWord == True:
            print(''.join(str))
            return

        for i in range(26):

            if root.children[i] is not None:
                ch = chr(97) + chr(i)
                str.append(ch)
                self.printKeysUtil(root.children[i] ,str)
                str.pop()
</code>```

答: You could perform a pre-order traversal of the nodes, and wherever you find an end-of-word marker, you zoom up to the root, capturing the letters as you go, in order to get the full word... except that to accomplish this, you would need to store the parent node in each node.</p>

Body:
I Implemented a Trie data structure using python, now the problem is it doesn't display the keys that Trie is stored in its data structure.

class Node:
    def __init__(self):
        self.children = [None] * 26
        self.endOfTheWord = False

class Trie:
    def __init__(self):
        self.root = self.getNode()

    def getNode(self):
        return Node()

    def charToIndex(self ,ch):
        return ord(ch) - ord('a')

    def insert(self ,word):
        current = self.root
        for i in range(len(word)):
            index = self.charToIndex(word[i])

            if current.children[index] is None:
                current.children[index] = self.getNode()

            current = current.children[index]

        current.endOfTheWord = True

    def printKeys(self):
        str = []
        self.printKeysUtil(self.root ,str)

    def printKeysUtil(self ,root ,str):

        if root.endOfTheWord == True:
            print(''.join(str))
            return

        for i in range(26):

            if root.children[i] is not None:
                ch = chr(97) + chr(i)
                str.append(ch)
                self.printKeysUtil(root.children[i] ,str)
                str.pop()


问:
Drag and drop multiple files by filter into listview
I'm currently have this code to store data to listview
I have to store first the info to textbox lines and then store them to listview.

Is there easy way without storing first textbox and directly put the files into listview?
What I want is to drag and drop or browse the multiple video ts file in the first column and then the srt in the sub column.
hope that you know what I mean. I'm rally new in listview

```<code>Sub AddToListView()
    LV.Items.Clear()
    Dim vn = vName.Lines
    Dim sn = sName.Lines
    Dim vp = vPath.Lines
    Dim sp = sPath.Lines

    Dim items As New List(Of ListViewItem)

    Dim upper = {vn.GetUpperBound(0), sn.GetUpperBound(0), vp.GetUpperBound(0), sp.GetUpperBound(0)}
    For I = 0 To upper.Min
        items.Add(New ListViewItem({vn(I), sn(I), vp(I), sp(I)}))
    Next
    LV.BeginUpdate()
    LV.Items.AddRange(items.ToArray())
    SortItems()
    LV.EndUpdate()
    AddToParam()
End Sub

Sub readFiles()
    Dim folder As String = txtinputFolder.Text
    Dim sb1 As New StringBuilder
    Dim sb2 As New StringBuilder
    Dim sb3 As New StringBuilder
    Dim sb4 As New StringBuilder

    For Each item In My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchTopLevelOnly, "*.ts")
        sb1.Append(item & vbNewLine)
    Next
    vPath.Text = ""
    vPath.Text = sb1.ToString.Trim

    For Each file As String In My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchTopLevelOnly, "*.ts")
        sb2.Append(Path.GetFileName(file) & vbNewLine)
    Next
    vName.Text = ""
    vName.Text = sb2.ToString.Trim

    For Each file As String In My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchTopLevelOnly, "*.srt")
        sb3.Append(Path.GetFileName(file) & vbNewLine)
    Next
    sName.Text = ""
    sName.Text = sb3.ToString.Trim

    For Each item3 In My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchTopLevelOnly, "*.srt")
        sb4.Append(item3 & vbNewLine)
    Next
    sPath.Text = ""
    sPath.Text = sb4.ToString.Trim
End Sub
</code>```

答:
If i'm not wrong subtitle name should be the same as the movie

```<code>Sub readFiles(ByVal searchdirectory As String)
    For Each FullPath In My.Computer.FileSystem.GetFiles(searchdirectory, FileIO.SearchOption.SearchTopLevelOnly, "*.ts")
        Dim parentPath As String = Path.GetDirectoryName(FullPath)
        Dim movieName As String = Path.GetFileNameWithoutExtension(FullPath)
        Dim srtPath As String = parentPath & "\" & movieName & ".srt"

        If File.Exists(srtPath) Then
            Lv.Items.Add(FullPath).SubItems.AddRange(New String() {movieName & ".ts", srtPath, movieName & ".srt"})
        Else
            Lv.Items.Add(FullPath).SubItems.AddRange(New String() {movieName & ".ts", "Not Exist", "No subtitle"})
        End If
    Next
    Lv.Sorting = SortOrder.Ascending
    Lv.Sort()
End Sub
</code>```

usage

```<code>readFiles("you path")
</code>```

Body:
I'm currently have this code to store data to listview
I have to store first the info to textbox lines and then store them to listview.

Is there easy way without storing first textbox and directly put the files into listview?
What I want is to drag and drop or browse the multiple video ts file in the first column and then the srt in the sub column.
hope that you know what I mean. I'm rally new in listview

Sub AddToListView()
    LV.Items.Clear()
    Dim vn = vName.Lines
    Dim sn = sName.Lines
    Dim vp = vPath.Lines
    Dim sp = sPath.Lines

    Dim items As New List(Of ListViewItem)

    Dim upper = {vn.GetUpperBound(0), sn.GetUpperBound(0), vp.GetUpperBound(0), sp.GetUpperBound(0)}
    For I = 0 To upper.Min
        items.Add(New ListViewItem({vn(I), sn(I), vp(I), sp(I)}))
    Next
    LV.BeginUpdate()
    LV.Items.AddRange(items.ToArray())
    SortItems()
    LV.EndUpdate()
    AddToParam()
End Sub

Sub readFiles()
    Dim folder As String = txtinputFolder.Text
    Dim sb1 As New StringBuilder
    Dim sb2 As New StringBuilder
    Dim sb3 As New StringBuilder
    Dim sb4 As New StringBuilder

    For Each item In My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchTopLevelOnly, "*.ts")
        sb1.Append(item & vbNewLine)
    Next
    vPath.Text = ""
    vPath.Text = sb1.ToString.Trim

    For Each file As String In My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchTopLevelOnly, "*.ts")
        sb2.Append(Path.GetFileName(file) & vbNewLine)
    Next
    vName.Text = ""
    vName.Text = sb2.ToString.Trim

    For Each file As String In My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchTopLevelOnly, "*.srt")
        sb3.Append(Path.GetFileName(file) & vbNewLine)
    Next
    sName.Text = ""
    sName.Text = sb3.ToString.Trim

    For Each item3 In My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchTopLevelOnly, "*.srt")
        sb4.Append(item3 & vbNewLine)
    Next
    sPath.Text = ""
    sPath.Text = sb4.ToString.Trim
End Sub

Body:
If i'm not wrong subtitle name should be the same as the movie

Sub readFiles(ByVal searchdirectory As String)
    For Each FullPath In My.Computer.FileSystem.GetFiles(searchdirectory, FileIO.SearchOption.SearchTopLevelOnly, "*.ts")
        Dim parentPath As String = Path.GetDirectoryName(FullPath)
        Dim movieName As String = Path.GetFileNameWithoutExtension(FullPath)
        Dim srtPath As String = parentPath & "\" & movieName & ".srt"

        If File.Exists(srtPath) Then
            Lv.Items.Add(FullPath).SubItems.AddRange(New String() {movieName & ".ts", srtPath, movieName & ".srt"})
        Else
            Lv.Items.Add(FullPath).SubItems.AddRange(New String() {movieName & ".ts", "Not Exist", "No subtitle"})
        End If
    Next
    Lv.Sorting = SortOrder.Ascending
    Lv.Sort()
End Sub

usage

readFiles("you path")


问:
HTML does not display as expected
I have 2 files,
test.html

<!DOCTYPE html>

<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

test1

test2

test3

test4

```
</div>
</div>
</p>

<p>end.html</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>info:No
Creation time:2020.05.01-17.03
Change the time: <script>document.write(document.lastModified);</script></code>```

There are two display effects:

Number One and Number Two

Reproducing this effect:

test1

test2

test3

test4

info:No

Creation time:2020.05.01-17.03

Change the time:05/24/2020 09:19:23

答:
test.html

```<code><!DOCTYPE html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="./test/jquery.min.js"></script>
</head>
<body>
<p>test1</p>
<p>test2</p>
<p>test3</p>
<p>test4</p>
<script src="end.js"></script>
</body>
</html>
</code>```

end.js

```<code>document.writeln("<p>info:No");
document.writeln("Creation time:2020.05.01-17.03</p>");
document.writeln("Change the time:<script>document.write(document.lastModified);</script>");
</code>```

ok

Title: HTML does not display as expected

Body:
I have 2 files,
test.html

<!DOCTYPE html>

<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

test1

test2

test3

test4

end.html

info:No
Creation time:2020.05.01-17.03
Change the time:

There are two display effects:

Number One and Number Two

Reproducing this effect:

test1

test2

test3

test4

info:No

Creation time:2020.05.01-17.03

Change the time:05/24/2020 09:19:23

Body:
test.html

<!DOCTYPE html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="./test/jquery.min.js"></script>
</head>
<body>
<p>test1</p>
<p>test2</p>
<p>test3</p>
<p>test4</p>
<script src="end.js"></script>
</body>
</html>

end.js

document.writeln("<p>info:No");
document.writeln("Creation time:2020.05.01-17.03</p>");
document.writeln("Change the time:<script>document.write(document.lastModified);</script>");

ok


问:
In bash, when sending a curl request, is there a way to break a very long url onto the next line?
For example, using two of the backslashes don't seem to help:</p>

```<code>curl "https://www.somewebsitethatjustkeepsgoing.com/jflawfelaifjliajsefaslaslfajslie&alksdjf \\
    ?andsomemore=2235233 \\
    --output my.pdf
</code>```

答:
A double backslash simply means "put a literal backslash here". If you want to extend a url across multiple lines, just use a single backslash...and no whitespace.  For example:</p>

```<code>curl goo\
gle.com
</code>```

Body:
For example, using two of the backslashes don't seem to help:

curl "https://www.somewebsitethatjustkeepsgoing.com/jflawfelaifjliajsefaslaslfajslie&alksdjf \\
    ?andsomemore=2235233 \\
    --output my.pdf

Body:
A double backslash simply means "put a literal backslash here". If you want to extend a url across multiple lines, just use a single backslash...and no whitespace.  For example:

curl goo\
gle.com


问:
What is the best way to know which protocols are supported by curl in python?
I am building a python application that is used to download remote files. In most cases, we use pycurl to do the actual download but we need to define a class that wraps the pycurl object. The class can handle several protocols (HTTP(S), FTP(S) and SFTP).

We have noticed that on some distributions (for example Ubuntu 18.04), cURL doesn't support the SFTP protocol. So using some SFTP-related options (SSH_KNOWNHOSTS for instance) leads to crashes (the crash occurs when setting the option before the download even if the URL uses another protocol). Therefore we need to know which protocols are available when the class is defined (i.e. when importing the module).

What is the best way to know, in python, which protocols are supported by cURL ? I know that the output of pycurl.version_info() contains the supported protocols (item 8) but is there a better way ?

答: pycurl does not track or check which protocols are supported by libcurl.</p>


问:
upper function not working for Latin-2 characters in KDB
I'm trying to run upper on a column that contains non-English characters: áéőí

```<code>q)t:([] nm: (`as;`$"áb"))
q)t
nm
---
as
áb
q)update upper_nm: upper nm from t
nm  upper_nm
------------
as  AS
áb áB
</code>```

I found a workaround using a system call to python but is much slower than the built-in function:

```<code>q)upper_py: {`$ system "python -c \"print(\\\"",string[x],"\\\".upper())\""}
q)update upper_nm: upper_py'[nm] from t
nm  upper_nm
------------
as  AS
áb ÁB
</code>```

There should be a nicer, faster way to do this.

答:
I don't think there is any built-in upper function in Q which supports such characters.

The cleanest way to get it is to bind it from .so But this approach is a bit of hassle

I would speed up you approach by passing list of string to python and parsing outcome to Q-list. This would prevent from calling system for every string:

```<code>t: ([] nm: (`as;`$"áb"));
toPythonList: {"[",("," sv "'",'x,'"'"),"]"};
pythonUpper: {system "python -c \"print([x.upper() for x in ",x,"])\""};
toQList: {-1_'1_'", " vs -1_1_x};
customUpper: {toQList first pythonUpper toPythonList x};
update upper_nm: customUpper string nm from t
</code>```

Body:
I'm trying to run upper on a column that contains non-English characters: áéőí

q)t:([] nm: (`as;`$"áb"))
q)t
nm
---
as
áb
q)update upper_nm: upper nm from t
nm  upper_nm
------------
as  AS
áb áB

I found a workaround using a system call to python but is much slower than the built-in function:

q)upper_py: {`$ system "python -c \"print(\\\"",string[x],"\\\".upper())\""}
q)update upper_nm: upper_py'[nm] from t
nm  upper_nm
------------
as  AS
áb ÁB

There should be a nicer, faster way to do this.

Body:
I don't think there is any built-in upper function in Q which supports such characters.

The cleanest way to get it is to bind it from .so But this approach is a bit of hassle

I would speed up you approach by passing list of string to python and parsing outcome to Q-list. This would prevent from calling system for every string:

t: ([] nm: (`as;`$"áb"));
toPythonList: {"[",("," sv "'",'x,'"'"),"]"};
pythonUpper: {system "python -c \"print([x.upper() for x in ",x,"])\""};
toQList: {-1_'1_'", " vs -1_1_x};
customUpper: {toQList first pythonUpper toPythonList x};
update upper_nm: customUpper string nm from t


问:
Point in rectangle
What is the fastest way to find if a point is in a rectangle given in this form:

I have two points which are the centers of opposite sides of the rectangle, and a number which is the height of those sides. I hope this is clear.

The rectangle is (probably) not aligned with the axis. I am wondering if there may be a faster algorithm given this data then calculating the four corners, rotating, etc.

An idea I though of but am not sure how to implement (having trouble with the math) was to find the distance from the point to the line traced between the two centers, and if it is  less then half the length of the side of the rectangle and also on the line then it is in the rectangle. I don't know how to explain this better.

Maybe the picture will help explain:

A, B, C are given, as well as the length of side A/B. Basically I thought that if CD is less then half of side A and D is on AB, the point is in the rectangle. But how do I do this?

Another thought: Instead of finding D to see if it is on AB, check if angles ABC and BAC are acute, but I still don't know how to do this.

答:
The following method is quite simple, but requires finding 1 vector length (you can cache it for multiple checks)

Calc vector AB = B - A

Calc AB length - it will be the width of the rectangle

If AB_length < TOLERANCE (tolerance is a small value, for example, TOLERANCE = 0.00000001) then the rectangle has zero width, therefore the point cannot lie in the rectangle

Normalize AB: AB_normalized = AB / AB_length

Calculate axis projections

Calc AB projection:

AB_proj = dot product(AB_normalized, C - A)

Calc AB orthogonal projection (denoted "CD" in your picture):

AB_orthogonal = (-AB.y, AB.x)

AB_orthogonal_proj = dot product(AB_orthogonal, C - A)

If  (0 <= AB_proj <= AB_length) and (ABS(AB_orthogonal_proj) <= AB_height / 2), then the point lies in the rectangle, doesn't lie otherwise

Title: Point in rectangle


问:
Xamarin: import SKBitmap from local file (not Resource)
I am pretty new in Xamarin so I hope I am not asking something stupid.

I would like to import a local image as SKBitmap (SkiaSharp Bitmap).

If I try using the simple Decode method, like

var skBitmap= SKBitmap.Decode("myImg.jpg");

my skBitmap is null.

I can load the image using

```<code>var myImg = ImageSource.FromFile("myImg.jpg");
</code>```

but how can I convert the ImageSourse to SKBitmap?

Any suggestion?
Thank you

答:
No matter you put the Image File to external file path or put the Image to xamarin forms project like following screenshot. Both of them you need read the image by standard .NET stream

For example. I put the image like above path.

Here is my layout.xaml

```<code>  <skia:SKCanvasView x:Name="hsvCanvasView" WidthRequest="200" HeightRequest="200"/>
</code>```

I want to set this Image to SKCanvasView. Here is background code

```<code> public partial class ItemsPage : ContentPage
    {
        ItemsViewModel viewModel;

        public ItemsPage()
        {
            InitializeComponent();
            hsvCanvasView.PaintSurface += HsvCanvasView_PaintSurface;

        }

        private void HsvCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
        {

            SKImageInfo info = args.Info;
            SKSurface surface = args.Surface;
            SKCanvas canvas = surface.Canvas;

            canvas.Clear();
            string resourceID = "App23.faded_div.jpg";
            Assembly assembly = GetType().GetTypeInfo().Assembly;
            SKBitmap bitmap;
            using (Stream stream = assembly.GetManifestResourceStream(resourceID))
            {

                 bitmap = SKBitmap.Decode(stream);
            }
            canvas.DrawBitmap(bitmap,200,200);
        }
</code>```

Here is running screenshot.

Here is a helpful artcle, you can refer to it.

https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/basics/bitmaps

Body:
I am pretty new in Xamarin so I hope I am not asking something stupid.

I would like to import a local image as SKBitmap (SkiaSharp Bitmap).

If I try using the simple Decode method, like

var skBitmap= SKBitmap.Decode("myImg.jpg");

my skBitmap is null.

I can load the image using

var myImg = ImageSource.FromFile("myImg.jpg");

but how can I convert the ImageSourse to SKBitmap?

Any suggestion?
Thank you

Body:
No matter you put the Image File to external file path or put the Image to xamarin forms project like following screenshot. Both of them you need read the image by standard .NET stream

For example. I put the image like above path.

Here is my layout.xaml

  <skia:SKCanvasView x:Name="hsvCanvasView" WidthRequest="200" HeightRequest="200"/>

I want to set this Image to SKCanvasView. Here is background code

 public partial class ItemsPage : ContentPage
    {
        ItemsViewModel viewModel;

        public ItemsPage()
        {
            InitializeComponent();
            hsvCanvasView.PaintSurface += HsvCanvasView_PaintSurface;

        }

        private void HsvCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
        {

            SKImageInfo info = args.Info;
            SKSurface surface = args.Surface;
            SKCanvas canvas = surface.Canvas;

            canvas.Clear();
            string resourceID = "App23.faded_div.jpg";
            Assembly assembly = GetType().GetTypeInfo().Assembly;
            SKBitmap bitmap;
            using (Stream stream = assembly.GetManifestResourceStream(resourceID))
            {

                 bitmap = SKBitmap.Decode(stream);
            }
            canvas.DrawBitmap(bitmap,200,200);
        }

Here is running screenshot.

Here is a helpful artcle, you can refer to it.

https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/basics/bitmaps


问:
Pandas mean vs sum/len
So this really baffled me. I was playing around with this Kaggle dataset using pandas to learn statistics. I tried to calculate the mean of a column by using Series.sum()/len(Series), but then I remembered that Series.mean() exists. However, I accidentally discovered that pandas Series.mean() gives a slightly different result from Series.sum()/len(Series).

Steps to reproduce:

- Read the dataset using pd.read_csv()

- Take the column MaxTemp as the Series we will work on, named 'workdata' for example.

- Calculate workdata.mean() and workdata.sum()/len(workdata)

For now, I suspect that the difference is because decimals cannot be calculated 100% correctly by a computer and there are lots of decimals to work with here so the small differences could pile up.

If it is indeed the case, which one would give a more accurate result, and why?

答:
This is because of Series.mean() doesn't count the NaN values in the dataFrame. if you want to include NaN values you can use Series.mean(skipna=False).

HAPPY_CODING...

Title: Pandas mean vs sum/len


问:
How to find broken links using Selenium WebDriver with Java
I want to verify broken links on a website and I am using this code: </p>

```<code> public static int invalidLink;
    String currentLink;
    String temp;

    public static void main(String[] args) throws IOException {
        // Launch The Browser
        WebDriver driver = new FirefoxDriver();
        // Enter URL
        driver.get("http://www.applicoinc.com");

        // Get all the links URL
        List<WebElement> ele = driver.findElements(By.tagName("a"));
        System.out.println("size:" + ele.size());
        boolean isValid = false;
        for (int i = 0; i < ele.size(); i++) {

            isValid = getResponseCode(ele.get(i).getAttribute("href"));
            if (isValid) {
                System.out.println("ValidLinks:" + ele.get(i).getAttribute("href"));
                driver.get(ele.get(i).getAttribute("href"));
                List<WebElement> ele1 = driver.findElements(By.tagName("a"));
                System.out.println("InsideSize:" + ele1.size());
                for (int j=0; j<ele1.size(); j++){
                    isValid = getResponseCode(ele.get(j).getAttribute("href"));
                    if (isValid) {
                        System.out.println("ValidLinks:" + ele.get(j).getAttribute("href"));
                    }
                    else{
                        System.out.println("InvalidLinks:"+ ele.get(j).getAttribute("href"));
                    }
                }

                } else {
                    System.out.println("InvalidLinks:"
                            + ele.get(i).getAttribute("href"));
                }

            }
        }
    }

    public static boolean getResponseCode(String urlString) {
        boolean isValid = false;
        try {
            URL u = new URL(urlString);
            HttpURLConnection h = (HttpURLConnection) u.openConnection();
            h.setRequestMethod("GET");
            h.connect();
            System.out.println(h.getResponseCode());
            if (h.getResponseCode() != 404) {
                isValid = true;
            }
        } catch (Exception e) {

        }
        return isValid;
    }

}
</code>```

答:
Steps:

1. Open a browser and navigate to TestURL

2. Grab all the links from the entire page

3. Check HTTP status code for all the links grabbed in step 2 (status 200 is OK, others are broken)

Selenium WebDriver Java code:

```<code>WebDriver driver = new FirefoxDriver();
driver.get("<TestURL>");
List<WebElement> total_links = driver.findElements(By.tagName("a"));
System.out.println("Total Number of links: " + total_links.size());
for(int i = 0; i < total_links.size(); i++){
String url = total_links.get(i).getAttribute("href");
int resp_Code = 0;
try{
HttpResponse urlresp = new DefaultHttpClient().execute(new HttpGet(url));
resp_Code = urlresp.getStatusLine().getStatusCode();
}catch(Exception e){
}
if(resp_Code >= 400){
System.out.println(url + " is a broken link");
}
else{
System.out.println(url + " is a valid link");
}
}
</code>```

Body:
I want to verify broken links on a website and I am using this code:

 public static int invalidLink;
    String currentLink;
    String temp;

    public static void main(String[] args) throws IOException {
        // Launch The Browser
        WebDriver driver = new FirefoxDriver();
        // Enter URL
        driver.get("http://www.applicoinc.com");

        // Get all the links URL
        List<WebElement> ele = driver.findElements(By.tagName("a"));
        System.out.println("size:" + ele.size());
        boolean isValid = false;
        for (int i = 0; i < ele.size(); i++) {

            isValid = getResponseCode(ele.get(i).getAttribute("href"));
            if (isValid) {
                System.out.println("ValidLinks:" + ele.get(i).getAttribute("href"));
                driver.get(ele.get(i).getAttribute("href"));
                List<WebElement> ele1 = driver.findElements(By.tagName("a"));
                System.out.println("InsideSize:" + ele1.size());
                for (int j=0; j<ele1.size(); j++){
                    isValid = getResponseCode(ele.get(j).getAttribute("href"));
                    if (isValid) {
                        System.out.println("ValidLinks:" + ele.get(j).getAttribute("href"));
                    }
                    else{
                        System.out.println("InvalidLinks:"+ ele.get(j).getAttribute("href"));
                    }
                }

                } else {
                    System.out.println("InvalidLinks:"
                            + ele.get(i).getAttribute("href"));
                }

            }
        }
    }

    public static boolean getResponseCode(String urlString) {
        boolean isValid = false;
        try {
            URL u = new URL(urlString);
            HttpURLConnection h = (HttpURLConnection) u.openConnection();
            h.setRequestMethod("GET");
            h.connect();
            System.out.println(h.getResponseCode());
            if (h.getResponseCode() != 404) {
                isValid = true;
            }
        } catch (Exception e) {

        }
        return isValid;
    }

}

Body:
Steps:

1. Open a browser and navigate to TestURL

2. Grab all the links from the entire page

3. Check HTTP status code for all the links grabbed in step 2 (status 200 is OK, others are broken)

Selenium WebDriver Java code:

WebDriver driver = new FirefoxDriver();
driver.get("<TestURL>");
List<WebElement> total_links = driver.findElements(By.tagName("a"));
System.out.println("Total Number of links: " + total_links.size());
for(int i = 0; i < total_links.size(); i++){
String url = total_links.get(i).getAttribute("href");
int resp_Code = 0;
try{
HttpResponse urlresp = new DefaultHttpClient().execute(new HttpGet(url));
resp_Code = urlresp.getStatusLine().getStatusCode();
}catch(Exception e){
}
if(resp_Code >= 400){
System.out.println(url + " is a broken link");
}
else{
System.out.println(url + " is a valid link");
}
}


问:
How do I append a value to each array item?
I have this code, it works but it just doesn't look right. I'm creating a string that I'm passing to the server through SSH:

```<code>... chmod -R 777 #{remote_path}/#{project}/#{items_to_chmod.join(' ' + remote_path + '/' + project + '/')} ...
</code>```

The ugly thing is the first "#{remote_path}/#{project}/", it's not being added to the first item value in the array.

答:
How about this?</p>

```<code>"... chmod -R 777 #{ items_to_chmod.map{ |item| File.join(remote_path, project, item) }.join(" ") } ..."
</code>```

Body:
I have this code, it works but it just doesn't look right. I'm creating a string that I'm passing to the server through SSH:

... chmod -R 777 #{remote_path}/#{project}/#{items_to_chmod.join(' ' + remote_path + '/' + project + '/')} ...

The ugly thing is the first "#{remote_path}/#{project}/", it's not being added to the first item value in the array.

Body:
How about this?

"... chmod -R 777 #{ items_to_chmod.map{ |item| File.join(remote_path, project, item) }.join(" ") } ..."


问:
Separation of internal and external users in Azure AD, but allow all to use Power BI Premium
Currently my team and I have a client that is using Power BI Premium.

We need to have Row Level Security enabled for both internal and external users.

We gave a recommendation to have Azure AD groups handle user management, but the client does not want to have all of there internal and external users be shown in their Azure AD.  They believe it will be unmanageable for them. They want us to recommend another way to be able to manage internal users in Azure AD and have all external users managed in Azure AD, but completely separated from internal users, or by some other user management service that Azure provides.  All the while, remaining in the same tenant since it seems the Power Bi Premium license can only be associated to one tenant and being able to have Row Level Security implemented for both internal and external users.

Is this possible?  If so, how can we do it?

Thank you all for your time and help.

答:
as per microsoft, https://learn.microsoft.com/en-us/power-bi/admin/service-admin-azure-ad-b2b
as far as I'm aware, the ideal way to share power bi with external users like that is this is to through azure b2b. which means you will have them as a guest user in your azure tenant. the second they are a guest in your tenant, that means they are on the list in your azure ad Users. which has advantages, their activity is trackable, reportable etc.

Our organizations has 10s of thousands of user accounts in our azure ad tenant, it doesn't make it any less manageable. just use the search bar or the filters, I'm not sure what the issue would be that makes it unmanageable.
if the requirement is secured power bi sharing,
you're better off trying to understand why your client thinks its unmanageable and help relieve their fears.

the only other option that I can see is, if you don't want to see external users, then you could use power BI embedded to embed power bi reports in a different web app that you create, and allow access to the webapp. but then you will have to deal with all the user level management stuff in code.
here's an article: https://medium.com/bi-helper/power-bi-embedded-report-distribution-to-external-users-1cf46fe1303b

hope this helps a bit.


问:
How to check if Azure Blob file Exists or Not
I want to check a particular file exist in Azure Blob Storage. Is it possible to check by specifying it's file name? Each time i got File Not Found Error.</p>

答:
With the latest version of SDK, you need to use the ExistsAsync Method,

```<code>public async Task<bool> FileExists(string fileName)
{
    return  await directory.GetBlockBlobReference(fileName).ExistsAsync();
}
</code>```

Here is the code sample.

Body:
With the latest version of SDK, you need to use the ExistsAsync Method,

public async Task<bool> FileExists(string fileName)
{
    return  await directory.GetBlockBlobReference(fileName).ExistsAsync();
}

Here is the code sample.