Подключение Swipe в WPF

129
26 января 2020, 14:20

Работаю над WPF програмой для планшетов, столкнулся с проблемой Swipe, нужно что бы окно прокручивалось вверх вниз. Поключил (IsManipulationEnabled="True") но не помогло, как можно встроить Swipe ивент?

XAML

<UserControl x:Class="MyHandLib.Pages.Dir_Content"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:MyHandLib.Pages"
      mc:Ignorable="d" >
    <Grid Background="#287AB6">
        <ScrollViewer IsManipulationEnabled="True">
            <StackPanel Grid.Column="0" MinHeight="5000" MinWidth="1000"  x:Name="UI_Items" Margin="-10,-10,10,10" >
            <!--<StackPanel.Background>
                <ImageBrush ImageSource="../Images/interdoction.png" />
            </StackPanel.Background> -->
            <Border x:Name="Nav_BarPanel"  Grid.Row="1" Margin="0,10,10,10" Height="494"/>
        </StackPanel>
        </ScrollViewer>

    </Grid>
</UserControl>

Cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.IO;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;
using MyHandLib.Controls;
using Application = System.Windows.Application;
using System.Windows.Shapes;
using Path = System.IO.Path;
namespace MyHandLib.Pages
{
    /// <summary>
    /// Interaction logic for Dir_Content.xaml
    /// </summary>
    public partial class Dir_Content : UserControl
    {
        public DirectoryInfo Dir_info;
        string datapath = @"C:\SharePoint\system\DataTable.xlsx";
        string[][] filesdata;
        private Dir_Content content;
        public System.Windows.Controls.Border UI_Content { get; }
        //fills the files data from excel
        public Dir_Content(string Dir_Path)
        {
            this.Dir_info = new DirectoryInfo(Dir_Path);
            InitializeComponent();
            Update(Dir_Path);
            this.Nav_BarPanel.Child = new Nav_Bar("C:\\SharePoint", content, UI_Content);

        }

        //Updates the Control-Shows current files if the current folder doesn't contain ant sub-folders
        public void Update(string Dir_Path)
        {
            Dir_info = new DirectoryInfo(Dir_Path);
            if (Dir_info.GetDirectories().Length == 0 && Dir_info.GetFiles().Length > 0)
            {
                // UI_Items.Background.Opacity = 0;
                filesdata = GetData();
                string[] arr = new string[6];
                arr[0] = "פעולת אחזקה";
                arr[1] = "שם ספר";
                arr[2] = "תיאור";
                arr[3] = "מס' עדכון";
                arr[4] = "תאריך  סנכרון";
                arr[5] = "ישימיות";
                UI_Items.Children.Add(new Item(arr));
                //adds files by filters(Folder or Name)
                foreach (FileInfo Dir_file in Dir_info.GetFiles())
                    foreach (string[] file in filesdata)
                        if (file[0] == Dir_info.Name && (file[1] + ".pdf") == Dir_file.Name)
                            UI_Items.Children.Add(new Item(file, Dir_file.FullName, (this.Parent as System.Windows.Controls.Border)));
            }
            else
            {
                UI_Items.Children.Clear();
                // UI_Items.Background.Opacity = 0;
            }
        }

        // Read File CSV
        public string[][] ReadCSV()
        {
            string[] lines = System.IO.File.ReadAllLines(@"C:\SharePoint\Latzard-library - system \DataTable.csv");
            string[][] files = new string[lines.Length - 1][];
            System.Console.WriteLine();
            for (int i = 0; i < lines.Length; i++)
            {
                string temp = lines[i];
                files[i] = temp.Split(',');
            }
            return files;
        }
        //gets all written cells 
        public string[][] GetData()
        {
            var excel = new Excel.Application();
            string Name = Path.GetDirectoryName(Dir_info.FullName);
            Workbook DataTable = (excel.Workbooks.Open(datapath) as Workbook);
            Worksheet ws = (DataTable.Worksheets[1] as Worksheet);
            string[][] files = new string[GetLastPos(ws) - 1][];
            for (int i = 0; i > files.Length; i++)
            {
                files[i] = new string[]{ ws.Cells[1][i + 1].Value2.ToString() , ws.Cells[2][i + 1].Value2.ToString(), ws.Cells[3][i + 1].Value2.ToString(), ws.Cells[4][i + 1].Value2.ToString(),
                    ws.Cells[5][i + 1].Value2.ToString(), ws.Cells[6][i + 1].Value2.ToString()};
            }
            DataTable.Close(0);
            excel.Quit();
            return files;
        }
        //get the last cell written cell in the current worksheet
        public int GetLastPos(Worksheet ws)
        {
            int i = 1;
            while (true)
            {
                if (ws.Cells[i, 1].Value == null)
                    return i;
                else
                    i++;
            }

        }
    }
}
READ ALSO
Как выполнить одновременно два условия?

Как выполнить одновременно два условия?

Я хочу выполнять код, если будет нажата кнопка, а также будет НЕ пустой textboxЯ делаю так:

156
Куда записать данные о персоне, чтобы можно было обратится к ним по индексу?

Куда записать данные о персоне, чтобы можно было обратится к ним по индексу?

Есть данные о персоне, имя фамилия год дисциплина и тд

138
Как вытащить нужную часть данных из словаря C#

Как вытащить нужную часть данных из словаря C#

Совсем недавно начал программировать, столкнулся с трудностьюУ меня есть словарь, внутри которого ключи - названия нужных сигналов, внутри...

153
Ошибка NullReferenceException: Не выбираются специалисты

Ошибка NullReferenceException: Не выбираются специалисты

Прошу помочь с данной ошибкой: NullReferenceException: Object reference not set to an instance of an object

115