Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用Xamarin和SQL Server在浏览器中显示数据库中的pdf_C#_Sql Server_Xamarin_Model View Controller_Xamarin.forms - Fatal编程技术网

C# 如何使用Xamarin和SQL Server在浏览器中显示数据库中的pdf

C# 如何使用Xamarin和SQL Server在浏览器中显示数据库中的pdf,c#,sql-server,xamarin,model-view-controller,xamarin.forms,C#,Sql Server,Xamarin,Model View Controller,Xamarin.forms,我有一个Xamarin形式的列表视图,您可以在这里的屏幕截图中看到: 这是我的数据库结构 正如你们在数据库中看到的,我有二进制格式的文件内容,这些二进制数据是pdf文件,我需要在浏览器中显示这些pdf 在我的listview中,我使用按钮检索数据,我想要的是,当用户单击按钮时,应根据id在浏览器中从数据库打开PDF文件 这是我的xaml代码 <ListView.ItemTemplate> <DataTemplate> <ViewCell&

我有一个Xamarin形式的列表视图,您可以在这里的屏幕截图中看到:

这是我的数据库结构

正如你们在数据库中看到的,我有二进制格式的文件内容,这些二进制数据是pdf文件,我需要在浏览器中显示这些pdf

在我的listview中,我使用按钮检索数据,我想要的是,当用户单击按钮时,应根据id在浏览器中从数据库打开PDF文件

这是我的xaml代码

<ListView.ItemTemplate>
    <DataTemplate>
        <ViewCell>
            <StackLayout Orientation="Vertical" Padding="12,6">
                <Label Text="{Binding ReportName}" 
                       FontSize="24" 
                       Style="{DynamicResource ListItemTextStyle}" />
                <Label Text="{Binding Date}"  
                       FontSize="18" 
                       Opacity="0.6"
                       Style="{DynamicResource ListItemDetailTextStyle}"/>
                  <Button Clicked="ShowPDF" Text="View" CommandParameter="{Binding FileContent}"></Button>
            </StackLayout>
        </ViewCell>
    </DataTemplate>
</ListView.ItemTemplate>

protected void ShowPDF(object sender, EventArgs args)
        {

            Button button = (Button)sender;

            string path = button.CommandParameter.ToString();



            Navigation.PushAsync(new PDFView(path));
        }

受保护的void ShowPDF(对象发送者、事件args args)
{
按钮=(按钮)发送器;
字符串路径=button.CommandParameter.ToString();
PushAsync(新的PDFView(path));
}

通常,当我必须使用xamarin表单显示pdf文件时,我会使用WebView,我可以为您提供的最佳示例是

另外,我最近在上看到了这个工作示例

祝你好运


如果你面临问题,请回复

到目前为止你做了什么上传了你的代码到目前为止我做了什么这是我的代码,但它不起作用,我知道我做错了
protectedvoid ShowPDF(object sender,EventArgs args){Button Button Button=(Button)sender;string path=Button.CommandParameter.ToString();Navigation.PushAsync(新PDFView(路径));}
这个问题有什么帮助吗?请以这种方式更新您的答案很难理解我已经更新了我的答案,但我知道我正在做的事情不应该像这样工作,因为我的数据库中有二进制数据,需要在浏览器中显示,所以此代码在allwell github页面不工作,我面临的问题是我的数据库中有二进制数据我的pdf数据库,我如何在webview中查看该数据?检查第一个链接它有步骤!我检查了该链接没有帮助,因为它显示了如何从本地路径显示pdf。对于我的情况,我的电脑中没有pdf以及它的数据库中的二进制数据,然后你可以做的是从数据库中获取它将其转换为pdf保存,然后所有的应用程序通常都是这么做的,我想你可能已经知道了