小编N. *_*ing的帖子

如何绑定SQLite的完整响应?

我正在ListView我的C#文件中.但是,我想要添加我从sqlite获得的数据以及带有数据绑定的xaml文件,所以我仍然可以使用xaml编辑布局.因此,sqlite的每个响应都需要添加为label(<TextCell Text="{Binding Name}" />).

我的问题:如何将响应绑定GetCategoryByMenuID到TextCell Text="{Binding Name}"

xaml页面(CategoriePage.xaml):

<?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="AmsterdamTheMapV3.CategoriePage">
  <ListView x:Name="listView">
    <ListView.ItemTemplate>
      <DataTemplate>
        <TextCell Text="{Binding Name}" />
      </DataTemplate>
    </ListView.ItemTemplate>
  </ListView>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

后端/ C#(CategoriePage.xaml.cs):

namespace AmsterdamTheMapV3
{
    public partial class CategoriePage : ContentPage
    {

        public CategoriePage(String txt)
        {
            InitializeComponent();
            var layout = new StackLayout { Padding = new Thickness(5, 10) };
            int page = Int32.Parse(txt);
            this.Content = layout;

            var categories = App.Database.GetCategoryByMenuID(page);

            var datatemplate = new DataTemplate(() …
Run Code Online (Sandbox Code Playgroud)

c# sqlite wpf xaml xamarin.forms

6
推荐指数
1
解决办法
310
查看次数

无法在Xaml上设置嵌套类的属性

Xamarin给出的错误:在xmlns clr-namespace中找不到类型Foo:AmsterdamTheMapV3

问题是我正在尝试定义Foo,但无论我做什么,它都会起作用.我认为问题出在xmls:local命名空间内.也许我在代码中犯了一个愚蠢的错误.

这是一个用于windows,android和apple的Xamarin.forms项目.

Xaml文件:

<?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="AmsterdamTheMapV3.CityGuide"
             xmlns:local="clr-namespace:AmsterdamTheMapV3">
  <Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
  <ScrollView Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
    <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"  Spacing="0">

      <!-- Button1 -->
      <Image
          x:Name="CityGuideButton1"
          Source="shopping_gray.png"
          Aspect="Fill"
          HorizontalOptions="FillAndExpand"
                VerticalOptions ="FillAndExpand"
          local:Foo.Tag="button1">
        <Image.GestureRecognizers>
          <TapGestureRecognizer
            Tapped="Categorie_Onclick"
            NumberOfTapsRequired="1"/>
        </Image.GestureRecognizers>
      </Image>
    </StackLayout>
  </ScrollView>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

Cs文件:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;

namespace AmsterdamTheMapV3
{
    public partial class CityGuide : ContentPage
    {
        public CityGuide()
        {
            InitializeComponent();
        }

         public class Foo …
Run Code Online (Sandbox Code Playgroud)

c# xaml android xamarin xamarin.forms

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

Xamarin Forms向视图添加标记

我的图像按钮有问题我希望我的功能Categorie_Onclick可以看到按钮被点击.我尝试添加标签,但它不起作用.有没有办法做到这一点?

XAML:

<!-- Button1 -->
<Image
  x:Name="CityGuideButton1"
  Source="shopping_gray.png"
  Aspect="Fill"
  HorizontalOptions="FillAndExpand"
  VerticalOptions ="FillAndExpand"
  Tag="01">
  <Image.GestureRecognizers>
    <TapGestureRecognizer
      Tapped="Categorie_Onclick"
      NumberOfTapsRequired="1"/>
  </Image.GestureRecognizers>
</Image>

<!-- Button2 -->
<Image
  x:Name="CityGuideButton2"
  Source="secrets.png"
  Aspect="Fill"
  HorizontalOptions="FillAndExpand"
  VerticalOptions ="FillAndExpand"
  Tag="02">
<Image.GestureRecognizers>
  <TapGestureRecognizer
    Tapped="Categorie_Onclick"
    NumberOfTapsRequired="1"/>
</Image.GestureRecognizers>
Run Code Online (Sandbox Code Playgroud)

按钮处理程序

private async void Categorie_Onclick(Object sender, EventArgs args)
{
    Image cmd = sender as Image;
    string txt = TapGestureRecognizer.tag.ToString();
    await Navigation.PushAsync(new CategoriePage());
}
Run Code Online (Sandbox Code Playgroud)

c# xaml xamarin xamarin.forms

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

标签 统计

c# ×3

xamarin.forms ×3

xaml ×3

xamarin ×2

android ×1

sqlite ×1

wpf ×1