小编mis*_*hut的帖子

UWP ListView项目上下文菜单

我在网上搜索如何添加上下文菜单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项目创建上下文菜单.

xaml contextmenu win-universal-app

7
推荐指数
1
解决办法
5914
查看次数

libGDX从精灵或纹理中获取像素颜色

我在网上搜索它,但我找不到任何解决方案.我有一个精灵或纹理,当我触摸它时,我想从触摸坐标获得像素颜色.

所以我有:

 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)

可能吗?谢谢 :)

android libgdx

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

如何垂直对齐控件?

我在 XML 文件中的屏幕上有几个元素

<layout:VerticalLayout xmlns:layout="sap.ui.layout" xmlns="sap.m">
  <Input />
  <Button />
  <!-- ... -->
</layout:VerticalLayout>
Run Code Online (Sandbox Code Playgroud)

如何添加布局重力或垂直对齐控件之类的内容?例如,我想要元素位于屏幕中央。

sapui5

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

单独文件夹中的 ListView DataTemplate

我正在尝试学习通用 Windows 平台的编程应用程序。我目前正在使用ListView,我在 中定义了它的布局<DataTemplate>,但代码是一团糟。有没有办法<DataTemplate>在单独的文件夹中定义?我搜索了网络,但我无法找到解决方案。你能帮我解决这个问题吗?谢谢。

xaml windows-10 uwp

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

Java - 注释处理器 - 未调用方法进程

我正在尝试实施AnnotationProcessor. 我正在关注本教程

我能够调试注释处理器,并且调试器转到方法:init, getSupportedAnnotationTypes, getSupportedOptionsgetSupportedSourceVersion但它不会转到process方法。

我无法在互联网上找到有用的东西。你能告诉我为什么会发生这种情况以及如何解决吗?

谢谢你。

java annotation-processing

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

UWP页面导航标识符

你好在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)

你能告诉我如何从我浏览的页面中找到答案吗?谢谢.

c# windows-10-mobile uwp

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

UWP - 使用分组过滤ListView

我有一个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 collectionviewsource windows-10 uwp

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

UWP - ListView滚动 - 不会停留在滚动位置

我有一个ListView分组.一切都很好,除了滚动.如果我想向下滚动ListView那么在释放之后ListView回到开头.我试图设置ScrollViewer.VerticalScrollModeEnabledScrollViewer.VerticalScrollBarVisibilityAuto.但没有成功.

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)

你能给我一些提示吗?因为我在网上搜索但没有任何解决方案.提前致谢.

xaml windows-10 uwp

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