简体   繁体   English

在 maui 中使用 [RelayCommand] 发送后,ViewModel 中的 setter 在 Maui 中收到截断的字符串

[英]After sending using [RelayCommand] in maui the setter in ViewModel receives truncated string in Maui

After sending using [RelayCommand] in maui the setter in ViewModel receives truncated string in Maui.在 maui 中使用 [RelayCommand] 发送后,ViewModel 中的 setter 在 Maui 中收到截断的字符串。 Example orginal string: "https://twit.memberfulcontent.com/rss/9039?auth=m9FZurRandomAuthonumbers6yB"原始字符串示例:“https://twit.memberfulcontent.com/rss/9039?auth=m9FZurRandomAuthonumbers6yB”

The value of URL is good here: URL 的值在这里很好:

[RelayCommand]
    async Task Tap(string Url)
    {
        System.Diagnostics.Debug.WriteLine("Tap Sending: " + Url);
        await Shell.Current.GoToAsync($"{nameof(ShowPage)}?Url={Url}");
    }

when recieving here URL is truncated:当在这里收到 URL 被截断时:


namespace NerdNewsNavigator2.ViewModel;

[QueryProperty("Url", "Url")]
public partial class ShowViewModel : ObservableObject
{
    #region Properties
    readonly TwitService _twitService;
    public ObservableCollection<Show> Shows { get; set; } = new();
    public string Url
    {
        set
        { // value is truncated string from Tap above.
            System.Diagnostics.Debug.WriteLine("ShowViewModel Recieving url: " + value);
            _ = GetShows(value);
            OnPropertyChanged(nameof(Shows));
        }
    }
// Code shortened for brevity

Example of passed string: "https://twit.memberfulcontent.com/rss/9039" It gets truncated at?Auth传递的字符串示例:“https://twit.memberfulcontent.com/rss/9039” 它在?Auth 处被截断

Any suggestions on what I may be doing wrong?关于我可能做错了什么的任何建议? Or suggestion on a better way to do this?或者建议更好的方法来做到这一点? It works fine for string that do not have a?它适用于没有? mark in them.在他们身上做记号。 One hundred percent working except on this specific type of string.除了这种特定类型的字符串外,百分百有效。

I was expecting the string not to be truncated.我期待字符串不会被截断。

Correct way to pass data between pages in MAUI: MAUI页面间数据传递的正确方式:

When you navigate:当您导航时:

Dictionary<string, object> query = new()
{
     { nameof(MyModel), myModel }
};
await Shell.Current.GoToAsync($"{nameof(MyPage)}", query);

When you are navigated:导航时:

public void ApplyQueryAttributes(IDictionary < string , object > query)
{ 
    myModel = query[nameof(MyModel)] as MyModel;
}

(This solves more than the problem with sanitization) (这不仅解决了消毒问题)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM