小编Ali*_*ren的帖子

Xamarin为android设置工具栏项的位置

我想要左侧的ToolbarItem Menu1,但此时两者都在右侧.我该如何解决这个问题?

<?xml version="1.0" encoding="UTF-8"?>
 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Dharma.LoginPage">
   <ContentPage.ToolbarItems>
     <ToolbarItem Name="Menu1" Order="Primary" Priority="0" />
     <ToolbarItem Name="Menu2" Order="Primary" Priority="1" />
   </ContentPage.ToolbarItems>
   <ContentPage.Content>
     <StackLayout Padding="30">
       <Label Text="Login Page" FontSize="20" />
     </StackLayout>
   </ContentPage.Content>
 </ContentPage>
Run Code Online (Sandbox Code Playgroud)

android xamarin xamarin.forms

7
推荐指数
2
解决办法
7336
查看次数

Xamarin表单:具有可绑定属性的IMarkupExtension不起作用

绑定不适用于Image标记.当我调试时,我看到Extension类中的Source值始终为null?但标签的内容不是空的.

XAML

<Label Text="{Binding Image}" />
<Image Source="{classes:ImageResource Source={Binding Image}}" />
Run Code Online (Sandbox Code Playgroud)

ImageResourceExtension

// You exclude the 'Extension' suffix when using in Xaml markup
[Preserve(AllMembers = true)]
[ContentProperty("Source")]
public class ImageResourceExtension : BindableObject, IMarkupExtension
{
    public static readonly BindableProperty SourceProperty = BindableProperty.Create(nameof(Source), typeof(string), typeof(string), null);
    public string Source
    {
        get { return (string)GetValue(SourceProperty); }
        set { SetValue(SourceProperty, value); }
    }

    public object ProvideValue(IServiceProvider serviceProvider)
    {
        if (Source == null)
            return null;

        // Do your translation lookup here, using whatever method you …
Run Code Online (Sandbox Code Playgroud)

binding bindable xamarin xamarin.forms

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

Scrollview中的Xamarin Forms Listview不会滚动

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
         x:Class="Dh.ListPage">
<ContentPage.Content>
    <ScrollView>
        <StackLayout Style="{StaticResource MainStackLayoutWhenLoggedInStyle}">
            <Frame Style="{StaticResource FrameStyle2}">
                <StackLayout>
                    <Label Text="Vragenlijsten" Style="{StaticResource TitelLabelStyle}" />
                </StackLayout>
            </Frame>
            <Frame Style="{StaticResource FrameStyle2}">
                <StackLayout>
                    <Label Text="DRINGENDE VRAGEN: vul deze vragen meteen in!" Style="{StaticResource StandardLabelStyle}"/>
                    <Frame Style="{StaticResource FrameStyle2}">
                        <StackLayout Style="{StaticResource ListViewStackLayoutStyle}" >
                            <ListView ItemTapped="OnItemTapped" ItemsSource="{Binding Question_Lists}" Style="{StaticResource StandardListViewStyle}">
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <ViewCell>
                                            <ViewCell.View>
                                                <Label Text="{Binding Title}" Style="{StaticResource StandardLabelStyle}" />
                                            </ViewCell.View>
                                        </ViewCell>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>
                        </StackLayout>
                    </Frame>
                </StackLayout>
            </Frame>
        </StackLayout>
    </ScrollView>
</ContentPage.Content>
Run Code Online (Sandbox Code Playgroud)

当我的屏幕太小时,我的列表视图不想滚动.如果我的屏幕不是太小,那么listview会滚动.有人可以帮我吗?

listview scrollview xamarin xamarin.forms

4
推荐指数
1
解决办法
5833
查看次数

Json DeserializeObject仅由iOS引发异常

Android没有这个问题,但是当我在iOS中运行相同的工作代码时,我会遇到异常

public async Task Login(string inlogData, string password, string gcm) 
    {
        Login login = new Dharma.Login ();
        login.inlog_data = inlogData;
        login.password = password;
        login.phone_token = gcm;

        HttpClient client = new HttpClient ();
        HttpResponseMessage response = null;

        string json = JsonConvert.SerializeObject(login, Formatting.Indented);
        client.Timeout = TimeSpan.FromMilliseconds (10000);
        client.BaseAddress = new Uri (ConstantVariabels.GetLoginUrl());
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

        var content = new StringContent (json, Encoding.UTF8, "application/json");

        try 
        {
            response = await client.PostAsync (client.BaseAddress, content);
            response.EnsureSuccessStatusCode ();
            var JsonResult = response.Content.ReadAsStringAsync ().Result;

            dynamic dynJson = JsonConvert.DeserializeObject(JsonResult);
            string …
Run Code Online (Sandbox Code Playgroud)

xamarin.ios xamarin xamarin.forms

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