标签: windows-phone-8.1

如何使用HTTPclient内容类型= application/x-www-form-urlencoded进行POST

我正在开发一个wp8.1应用程序C#,我已经设法通过从textbox.texts创建一个json对象(bm)来在json中执行一个POST方法到我的api.这是我的代码如下.我如何使用相同的textbox.text并将它们作为内容类型= application/x-www-form-urlencoded进行POST.那是什么代码?

            Profile bm = new Profile();
            bm.first_name = Names.Text;
            bm.surname = surname.Text;

            string json = JsonConvert.SerializeObject(bm);

            MessageDialog messageDialog = new MessageDialog(json);//Text should not be empty 
            await messageDialog.ShowAsync();

            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");

            byte[] messageBytes = Encoding.UTF8.GetBytes(json);
            var content = new ByteArrayContent(messageBytes);
            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var response = client.PostAsync("myapiurl", content).Result;
Run Code Online (Sandbox Code Playgroud)

c# windows-phone-8.1

72
推荐指数
3
解决办法
7万
查看次数

Universal Apps MessageBox:"当前上下文中不存在名称'MessageBox'"

我想使用MessageBox在我的WP8.1应用程序中显示下载错误.

我补充说:

using System.Windows;
Run Code Online (Sandbox Code Playgroud)

但是当我键入:

MessageBox.Show("");
Run Code Online (Sandbox Code Playgroud)

我收到错误:

"The name 'MessageBox' does not exist in the current context"
Run Code Online (Sandbox Code Playgroud)

在对象浏览器中,我发现这样的类应该存在,并且在"Project-> Add reference ... - > Assemblies-> Framework"中显示所有程序集都被引用.

我错过了什么吗?或者还有另一种方式来展示像messagebox这样的东西?

c# windows-phone-8.1 win-universal-app

60
推荐指数
3
解决办法
8万
查看次数

在Windows Phone 8.1 Universal Apps中隐藏状态栏

如何在Windows Phone 8.1(C#,XAML)中隐藏状态栏?

Windows Phone 8它被设置做shell:SystemTray.IsVisible="False"任何页面.但它没有Windows Phone 8.1

c# winrt-xaml windows-phone-8.1 win-universal-app

48
推荐指数
2
解决办法
2万
查看次数

使用Windows RT的客户端证书(Windows 8.1/Windows Phone 8.1)

我正在尝试Windows 8.1和Windows Phone 8.1的新功能,即证书存储和在服务器端使用客户端证书进行客户端身份验证的可能性.但是我遇到了这个功能的问题.

我有一个基本测试的WCF服务,它运行在IIS Express上.IIS express配置为支持SSL和客户端证书.在IIS(configurationhost.config)的配置文件中,我设置了这个:

<access sslFlags="SslRequireCert" /> (tried also SslNegotiateCert)
<clientCertificateMappingAuthentication enabled="true" />
Run Code Online (Sandbox Code Playgroud)

我在Windows RT应用程序中添加了客户端证书,如下所示:

//Install the self signed client cert to the user certificate store
string CACertificate = null;
try
{
    Uri uri = new Uri("ms-appx:///Assets/AdventureWorksTestClient1.pfx");
    var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);
    IBuffer buffer = await FileIO.ReadBufferAsync(file);
    using (DataReader dataReader = DataReader.FromBuffer(buffer))
    {
       byte[] bytes = new byte[buffer.Length];
       dataReader.ReadBytes(bytes);
       // convert to Base64 for using with ImportPfx
       CACertificate = System.Convert.ToBase64String(bytes);
    }
    await CertificateEnrollmentManager.UserCertificateEnrollmentManager.ImportPfxDataAsync(
            CACertificate,
            "", …
Run Code Online (Sandbox Code Playgroud)

c# client-certificates windows-runtime windows-8.1 windows-phone-8.1

42
推荐指数
1
解决办法
1817
查看次数

滑动(后退和前进)时禁用网页导航

在Windows手机上,如果滑动来自边缘,则IE用户可以通过在屏幕上滑动来前后移动.此操作系统级功能阻碍了我的网页用户体验.

是否有任何js或css可以禁用它?一些黑客也会这样做.

来自windowsphone网站的快照: 在此输入图像描述

以下是参考页面的链接:http://www.windowsphone.com/en-in/how-to/wp8/basics/gestures-swipe-pan-and-stretch

请注意,我仍然需要启用水平滚动的触摸功能.

javascript css internet-explorer windows-phone-8 windows-phone-8.1

38
推荐指数
3
解决办法
1万
查看次数

Windows Phone 8.1 - 页面导航

来自Windows Phone 8我从未想过将对代码进行大量更改Windows Phone 8.1.基本上我只是想知道如何进行页面导航就像你将如何进行一样Windows Phone 8.要做到这一点,你应该添加:

NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative));
Run Code Online (Sandbox Code Playgroud)

但该代码不起作用Windows Phone 8.1.

有人可以帮我这个吗?如果可能,请提供有关所有新Windows Phone 8.1方法的任何链接或文档.

c# windows-phone-8 windows-phone-8.1

37
推荐指数
2
解决办法
5万
查看次数

以编程方式动画(平滑)ScrollViewer

有没有办法ScrollViewer在Windows Phone 8.1 Runtime中平滑地设置垂直偏移量?

我尝试过使用该ScrollViewer.ChangeView()方法,无论是否将disableAnimation参数设置为true或false,都不会对垂直偏移的更改进行动画处理.

例如:myScrollViewer.ChangeView(null, myScrollViewer.VerticalOffset + p, null, false); 偏移在没有动画的情况下更改.

我也试过使用垂直偏移中介:

/// <summary>
/// Mediator that forwards Offset property changes on to a ScrollViewer
/// instance to enable the animation of Horizontal/VerticalOffset.
/// </summary>
public sealed class ScrollViewerOffsetMediator : FrameworkElement
{
    /// <summary>
    /// ScrollViewer instance to forward Offset changes on to.
    /// </summary>
    public ScrollViewer ScrollViewer
    {
        get { return (ScrollViewer)GetValue(ScrollViewerProperty); }
        set { SetValue(ScrollViewerProperty, value); }
    }
    public static …
Run Code Online (Sandbox Code Playgroud)

c# windows-runtime winrt-xaml windows-phone-8.1

36
推荐指数
1
解决办法
5078
查看次数

System.Net HttpStatusCode类没有代码422

有没有办法优雅地处理http状态代码422.我在这里寻找最好的做法.我知道HttpStatusCode是一个枚举所以我试过的是这个,

HttpStatusCode Unprocessable = (HttpStatusCode)422;
if (Response == (HttpStatusCode)422)
Run Code Online (Sandbox Code Playgroud)

但是不允许我比较它.我在这里做错了吗?

什么是在运行时添加此状态代码的最佳方法.

c# rest http-status-codes windows-phone-8.1

36
推荐指数
2
解决办法
1万
查看次数

挂起事件不使用WinRT引发

我在使用WinRT在Windows Phone 8.1上暂停事件时遇到问题,它不会触发.我不知道为什么.这是我的代码:

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
    InitializeComponent();

    Suspending += OnSuspending;
#if DEBUG
    this.displayRequest = new DisplayRequest();
#endif
}

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory …
Run Code Online (Sandbox Code Playgroud)

c# windows-runtime windows-phone-8.1 win-universal-app uwp

35
推荐指数
1
解决办法
8360
查看次数

JSON.NET DeserializeObject到对象列表

我正在尝试使用JSON.NET lib将对象反序列化为对象列表.我的json文件是:

[
{
    "id": 1,
    "name": "Poczta",
    "description": "Opis",
    "latitude": 52.25197,
    "longitude": 20.896355,
    "accuracy": 0,
    "type": "",
    "image": null
},
{
    "id": 2,
    "name": "WAT",
    "description": "Budynek g?ówny - sztab.\r\nza?ó?? g??l? ja??",
    "latitude": 52.2531213,
    "longitude": 20.8995849,
    "accuracy": 0,
    "type": "Uczelnia",
    "image": null
},
{
    "id": 3,
    "name": "Przychodnia",
    "description": "Opis",
    "latitude": 52.250808,
    "longitude": 20.895348,
    "accuracy": 0,
    "type": "",
    "image": null
},
{
    "id": 4,
    "name": "DS3",
    "description": "Opis",
    "latitude": 52.250063,
    "longitude": 20.895847,
    "accuracy": 0,
    "type": "",
    "image": null
}, …
Run Code Online (Sandbox Code Playgroud)

c# json.net windows-store-apps windows-phone-8.1

32
推荐指数
1
解决办法
5万
查看次数