我在网上搜索如何添加上下文菜单ListView
.到目前为止,我发现了一个实际显示上下文的内容
<ListView>
...
RightTapped="ContactsListView_RightTapped" >
...
<ListView.Resources>
<MenuFlyout x:Name="allContactsMenuFlyout">
<MenuFlyout.Items>
<MenuFlyoutItem x:Name="Edit" Text="Edit"/>
<MenuFlyoutItem x:Name="Remove" Text="Remove" Click="Remove_Click"/>
</MenuFlyout.Items>
</MenuFlyout>
</ListView.Resources>
...
</ListView>
private void ContactsListView_RightTapped(object sender, RightTappedRoutedEventArgs e) {
ListView listView = (ListView)sender;
allContactsMenuFlyout.ShowAt(listView, e.GetPosition(listView));
}
private void Remove_Click(object sender, RoutedEventArgs e) {
}
Run Code Online (Sandbox Code Playgroud)
问题是我无法获得显示上下文菜单的项目.另一个问题是上下文菜单也显示在列表视图项之外(例如,在边框上).由于触发的事件是RightTapped,我不确定是否会在长按移动设备上显示上下文菜单.我无法测试它,因为我的模拟器当前不工作.因为它应该是通用的Windows应用程序,我期待一些非常简单有效的方法为ListView项目创建上下文菜单.
我在网上搜索它,但我找不到任何解决方案.我有一个精灵或纹理,当我触摸它时,我想从触摸坐标获得像素颜色.
所以我有:
if (Gdx.input.isTouched()) {
Rectangle spriteBounds = sprite.getBoundingRectangle();
if (sprite.contains(Gdx.input.getX(), Gdx.input.getY())) {
//and here something like
//Color color = sprite.getPixelColor(Gdx.input.getX(), Gdx.input.getY());
}
}
Run Code Online (Sandbox Code Playgroud)
可能吗?谢谢 :)
我在 XML 文件中的屏幕上有几个元素
<layout:VerticalLayout xmlns:layout="sap.ui.layout" xmlns="sap.m">
<Input />
<Button />
<!-- ... -->
</layout:VerticalLayout>
Run Code Online (Sandbox Code Playgroud)
如何添加布局重力或垂直对齐控件之类的内容?例如,我想要元素位于屏幕中央。
我正在尝试学习通用 Windows 平台的编程应用程序。我目前正在使用ListView
,我在 中定义了它的布局<DataTemplate>
,但代码是一团糟。有没有办法<DataTemplate>
在单独的文件夹中定义?我搜索了网络,但我无法找到解决方案。你能帮我解决这个问题吗?谢谢。
我正在尝试实施AnnotationProcessor
. 我正在关注本教程。
我能够调试注释处理器,并且调试器转到方法:init
, getSupportedAnnotationTypes
, getSupportedOptions
,getSupportedSourceVersion
但它不会转到process
方法。
我无法在互联网上找到有用的东西。你能告诉我为什么会发生这种情况以及如何解决吗?
谢谢你。
你好在UWP我可以导航到另一个页面,如:
Frame.Navigate(typeof(AnotherPage), someObject);
Run Code Online (Sandbox Code Playgroud)
在AnotherPage
如果我想要检索的对象:
protected override void OnNavigationTo(NavigationEventArgs e) {
SomeObject someObject = (SomeObject) e.Parameter;
//here I would like to know from what page I am navigating
}
Run Code Online (Sandbox Code Playgroud)
你能告诉我如何从我浏览的页面中找到答案吗?谢谢.
我有一个ListView
分组.我想ListView
根据输入的文字显示此项目TextBox
.有许多关于过滤ListView
和的教程CollectionViewSource
,但它们WPF
不是UWP
.我在做什么:
我的ListView
:
<ListView x:Name="ContactsListView"
ItemTemplate="{StaticResource ContactsTemplate}"
ItemsSource="{x:Bind ContactsViewSource.View}"
SelectionMode="Single"
ShowsScrollingPlaceholders="True" >
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate x:DataType="data:GroupingItem">
<TextBlock Text="{x:Bind Key}"
Foreground="Blue"
Style="{ThemeResource TitleTextBlockStyle}"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
Run Code Online (Sandbox Code Playgroud)
我CollectionViewSource
的定义是Page.Resources
:
<CollectionViewSource x:Name="ContactsViewSource"
x:Key="src"
IsSourceGrouped="True" />
Run Code Online (Sandbox Code Playgroud)
我创建了一个textChanged
事件处理程序TextBox
:
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e) {
....
//here I filter ListView items and add them to CollectionViewSource
ContactsViewSource.Source = filteredValues;
} …
Run Code Online (Sandbox Code Playgroud) 我有一个ListView
分组.一切都很好,除了滚动.如果我想向下滚动ListView
那么在释放之后ListView
回到开头.我试图设置ScrollViewer.VerticalScrollMode
到Enabled
和ScrollViewer.VerticalScrollBarVisibility
到Auto
.但没有成功.
XAML代码:
<PivotItem>
<StackPanel Orientation="Vertical" >
<TextBox x:Name="SearchBox"
PlaceholderText="Search ... "
TextChanged="SearchBox_TextChanged"/>
<ListView x:Name="ContactsListView"
ItemTemplate="{StaticResource ContactsTemplate}"
ItemsSource="{x:Bind ContactsViewSource.View}"
SelectionMode="Single"
ScrollViewer.VerticalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Auto" >
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate x:DataType="data:GroupingItem">
<TextBlock Text="{x:Bind Key}"
Foreground="Blue"
Style="{ThemeResource TitleTextBlockStyle}"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
</StackPanel>
</PivotItem>
Run Code Online (Sandbox Code Playgroud)
你能给我一些提示吗?因为我在网上搜索但没有任何解决方案.提前致谢.
uwp ×4
windows-10 ×3
xaml ×3
android ×1
c# ×1
contextmenu ×1
java ×1
libgdx ×1
listview ×1
sapui5 ×1