C# Xamarin:是否可以单击BoxView中的项目并;围棋;下一页?
我的应用程序中有一个侧菜单,当你向左滑动时会显示。侧菜单基本上是一个包含菜单项列表的BoxView,如设置和登录 我的问题是:是否可以单击BoxView中的特定项目?例如设置。 我已尝试通过MainPage.cs中的创建方法使项目可单击。没有真正起作用 这里有一些代码,以备您需要 MainPage.cs:C# Xamarin:是否可以单击BoxView中的项目并;围棋;下一页?,c#,asp.net,xamarin.forms,xamarin.android,xamarin-studio,C#,Asp.net,Xamarin.forms,Xamarin.android,Xamarin Studio,我的应用程序中有一个侧菜单,当你向左滑动时会显示。侧菜单基本上是一个包含菜单项列表的BoxView,如设置和登录 我的问题是:是否可以单击BoxView中的特定项目?例如设置。 我已尝试通过MainPage.cs中的创建方法使项目可单击。没有真正起作用 这里有一些代码,以备您需要 MainPage.cs: private List<Menu> GetMenus() { return new List<Menu
private List<Menu> GetMenus()
{
return new List<Menu>
{
new Menu { Title = "Home", Type = ButtonType.Home, Icon = "Icon.Images.icon.png"},
new Menu { Title = "Settings", Type = ButtonType.Settings, Icon = "Icon.Images.icon.png"},
new Menu { Title = "Rotate", Type = ButtonType.Rotate, Icon = "Icon.Images.icon.png"},
};
}
private void OpenSwipe(object sender, EventArgs e)
{
}
private void CloseSwipe(object sender, EventArgs e)
{
}
private List GetMenus()
{
返回新列表
{
新菜单{Title=“Home”,Type=ButtonType.Home,Icon=“Icon.Images.Icon.png”},
新菜单{Title=“Settings”,Type=ButtonType.Settings,Icon=“Icon.Images.Icon.png”},
新菜单{Title=“Rotate”,Type=ButtonType.Rotate,Icon=“Icon.Images.Icon.png”},
};
}
私有void OpenSwipe(对象发送方,事件参数e)
{
}
私有void closeswip(对象发送方,事件参数e)
{
}
我现在得到的结果是,每次我点击菜单项时,侧菜单再次关闭
MainPage.xaml
<Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<!--<Image Aspect="Fill" Source="icon.png" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"></Image>-->
<BoxView BackgroundColor="DarkSlateGray" Opacity="0.9">
</BoxView>
<SwipeView x:Name="MainSwipeView" BackgroundColor="Transparent">
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItemView>
<Grid>
<StackLayout Spacing="20" Padding="35" WidthRequest="100" BindableLayout.ItemsSource="{Binding MyMenu}"
VerticalOptions="CenterAndExpand">
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="CloseSwipe">
</TapGestureRecognizer>
</StackLayout.GestureRecognizers>
<pancakeView:PancakeView HeightRequest="30"
WidthRequest="30" CornerRadius="15" VerticalOptions="Center"
HorizontalOptions="Start">
<ImageButton Source="{Binding icon.png}" HeightRequest="15" WidthRequest="15" VerticalOptions="Center"
HorizontalOptions="Center"></ImageButton>
</pancakeView:PancakeView>
<Label Text="{Binding Title}" TextColor="Black" FontSize="15" FontAttributes="Bold"
HorizontalOptions="Start" VerticalOptions="Center"></Label>
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</Grid>
</SwipeItemView>
</SwipeItems>
</SwipeView.LeftItems>
<Grid x:Name="swipeContent">
<pancakeView:PancakeView x:Name="WebView1" Background="Gray">
<Grid AbsoluteLayout.LayoutBounds="1,1,1,1" AbsoluteLayout.LayoutFlags="All">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Padding="30">
<Image Source="{iconWareApp:ImageResource iconWareApp.Images.icon.png}" HeightRequest="18" HorizontalOptions="Start">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OpenSwipe" ></TapGestureRecognizer>
</Image.GestureRecognizers>
</Image>
<ImageButton Source="{iconWareApp:ImageResource iconWareApp.Images.icon.png}" HeightRequest="36" HorizontalOptions="End" ></ImageButton>
</Grid>
<Grid AbsoluteLayout.LayoutBounds="1,1,1,1" AbsoluteLayout.LayoutFlags="All">
<views:HybridWebView x:Name="WebView" />
</Grid>
<views:MenuView HorizontalOptions="Start" VerticalOptions="Start"></views:MenuView>
</Grid>
</Grid>
</pancakeView:PancakeView>
</Grid>
</SwipeView>
</Grid>
更新:
private List<Menu> GetMenus()
{
return new List<Menu>
{
new Menu { Title = "Home", Type = ButtonType.Home, Icon = "Icon.Images.icon.png"},
new Menu { Title = "Settings", Type = ButtonType.Settings, Icon = "Icon.Images.icon.png"},
new Menu { Title = "Rotate", Type = ButtonType.Rotate, Icon = "Icon.Images.icon.png"},
};
}
private void OpenSwipe(object sender, EventArgs e)
{
}
private void CloseSwipe(object sender, EventArgs e)
{
}
我的意思是,我有一个侧菜单,其中有3个菜单项,在这种情况下,我想进入设置。(我使用BOXVIEW更改侧菜单的颜色)
看一看这张图片。这些项目(主页、设置、主页)应该将我带到其他页面,但它们不会这样做。这就是我的问题。我在代码中看到的唯一一个BoxView是空的,所以我不确定它有什么相关性?是的,它是空的,我不知道是否应该填充它。。我对xamarn表单很陌生@杰索尼不知道你希望我们告诉你什么。是的,可以在BoxView中单击某个项目(使用手势识别器),但这似乎与您发布的代码无关。您刚刚告诉我我需要知道的是:D@Jason您可以给我一个例子吗?什么的例子?你已经在使用手势识别器了,所以我想你知道它是如何工作的。