xaml - XAML 绑定在发布模式下不工作,但在调试模式下工作
问题描述
我正在使用CarouselView
绑定到的 aIEnumerable<T> list
以在该列表中显示我的文件的预览以及文件名,并将文件路径用作图像预览。
当我调试我的应用程序时,此绑定按预期工作,文件名和图像预览根据每个文件按预期显示。但是,当我在发布模式下测试我的应用程序时,文件名的绑定失败,而我的文件路径的绑定仍然有效。
为了向您展示我的意思,以下是 Debug 和 Release 的一些屏幕截图:
应用程序应该像调试屏幕截图一样运行,其中文件名在框架顶部可见。
这是我的 XAML 和代码隐藏,以便更好地了解出了什么问题:
XAML:
<!--Carousel of files selected preview with binding to the Files variable in the codebehind-->
<CarouselView x:Name="preview" IsVisible="True" ItemsSource="{Binding Files}" PeekAreaInsets="20" >
<CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout>
<Frame HasShadow="True"
IsVisible="True"
BorderColor="Black"
CornerRadius="5"
Margin="5,10,5,10"
HeightRequest="500"
WidthRequest="500"
HorizontalOptions="Center"
VerticalOptions="Start">
<StackLayout>
<Label TextColor="Black" Text="{Binding FileName}" IsVisible="True"></Label>
<Image Source="{Binding FullPath}"
Aspect="AspectFill"
HeightRequest="500"
WidthRequest="500"
VerticalOptions="Center"/>
</StackLayout>
</Frame>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
代码隐藏:
//<--Summary: Gives users a preview of the files they selected before uploading-->
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class FileView : ContentPage
{
public static string fileID; //Upload filename
private IEnumerable<FileResult> pickedFiles; //List of picked files
public IEnumerable<FileResult> Files {
get => pickedFiles;
}
public string SelectedTime { get; set; } //Binding for user selected transfer time
public bool SelectedCompression { get; set; } //Binding for user selected compression type
public FileView( IEnumerable<FileResult> pF)
{
InitializeComponent();
SelectedTime = "1"; //Sets default transfer time to 1 minute
this.pickedFiles = pF;
this.BindingContext = this;
}
解决方案
推荐阅读
- java - ClassCastException:为什么不能将我的 CrossOriginResourceSharingFilter 转换为 GlassFish Server 中的 javax.servlet.Filter
- html - 当我想要多个值时,角度复选框仅选择一个值数据
- wcf - WCF 消费者在超时限制内没有得到响应,尽管服务本身已经完成
- cloudera - 色调服务错误:无法连接到 quickstart.cloudera:21050
- excel - 宏在循环中复制内容需要更多时间
- php - 查找某个字符并在循环中删除它
- c# - C# 等效于 PowerShell Invoke-RestMethod -Token
- java - Java 客户端/服务器聊天应用程序
- python - Python 不断返回一个断言错误,但我不知道我哪里出错了
- python - 虽然循环不会中断并无限运行(Python)