小编yal*_*tta的帖子

在UWP Windows 10 C中创建带边框的圆形按钮#

我试图在UWP Windows 10中创建一个带有白色边框和透明背景(如Windows 8.1中的旧AppBarButtons)的圆形按钮.

我找到了几个这样的样本:

https://comentsys.wordpress.com/2015/05/23/windows-10-universal-windows-platform-custom-button/

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/cda7a526-5e99-4d4a-a73c-0be4ce77f961/uwpwindows10-how-to-make-button-with-round-edges?forum=wpdevelop&prof=需要

但问题在于边境问题.当我将BorderBrush设置为某​​种颜色时,结果是边框是Button的"矩形".

有没有办法为按钮创建圆形边框?

c# xaml button win-universal-app

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

HttpClient.GetStringAsync(url)抛出"底层连接已关闭:发送时发生意外错误".Windows 8.1 C#

我正在创建一个新的Windows 8.1应用程序,只是为了测试我得到的这个错误.该应用程序只有一个功能:

private async void TestMethod()
        {
            try
            {                       
                HttpClient httpClient = new HttpClient();
                HttpResponseMessage response = await httpClient.GetAsync("https:// url ");                    
            }
            catch (HttpRequestException e)
            {
                string s = e.InnerException.Message;
            }
        }
Run Code Online (Sandbox Code Playgroud)

它始终进入捕获并抛出"底层连接已关闭:发送时发生意外错误".我发现很多问题都提到了,但没有解决方案对我有用,因为这是Windows 8.1 Store应用程序而不是ASP.NET应用程序.

我正在使用的Uri在浏览器中打开并且运行良好.

我甚至得到了这篇文章:https://support.microsoft.com/en-us/kb/915599但没有解决方案.以前有人遇到过这个问题吗?

编辑:

我改变了使用方法 async Task

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection …

c# exception httpclient windows-8.1

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

计算水平偏移以将ListView滚动到SelectedItem的中心

我正在构建一个照片应用程序,使用a FlipView和a listView作为分页.当我点击它中的缩略图时,ListView它显示了我的相同图片FlipView.当我滑入时FlipView,所选的任何照片都会选择相同的照片ListView.这是通过添加到它们两个来完成的:

ListView:

SelectedIndex="{Binding Path=SelectedIndex, ElementName=flipView1, Mode=TwoWay}
Run Code Online (Sandbox Code Playgroud)

对于FlipView:

SelectedIndex="{Binding Path=SelectedIndex, ElementName=listView1, Mode=TwoWay}
Run Code Online (Sandbox Code Playgroud)

对于ListView SelectionChanged我添加的事件:

 if (e.AddedItems.Count > 0)
        listView1.ScrollIntoView(e.AddedItems.First(), ScrollIntoViewAlignment.Leading);
Run Code Online (Sandbox Code Playgroud)

我唯一的问题是,当我滑动时FlipView,所选的图片被选中,ListView但是ScrollViewer没有滚动到它.我尝试WinRTXamlToolkit用来改变以下位置ScrollViewer:

private void pageRoot_Loaded()
        {
            // count number of all items
            int itemCount = this.listView1.Items.Count;
            if (itemCount == 0)
                return;

            if (listView1.SelectedIndex >= itemCount)
                listView1.SelectedIndex = itemCount - 1;

            // calculate x-posision of …
Run Code Online (Sandbox Code Playgroud)

c# listview scrollviewer windows-store-apps windows-8.1

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

使用LiveData时检查RoomDatabase是否为空

我正在尝试RoomDatabase在我的Android应用中使用。而且我习惯于LiveData能够自动刷新片段中的更改。

第一次运行我的应用程序时,我是从API中获取数据,创建RoomDatabase并存储数据。

第二次运行我的应用程序时,我想检查数据库是否为空。但是在使用时LiveData,以下代码返回null。

AppDatabase.getInstance(getContext()).getRecipeDao().getAllRecipes().getValue();
Run Code Online (Sandbox Code Playgroud)

我已经读过“如果响应是可观察的数据类型,例如Flowable或LiveData,Room会监视查询中引用的所有表是否无效”。

如何检查我的RoomDatabase是否有数据或为空?

android dao android-room android-livedata

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

在Windows应用商店应用中加密和解密本地图像

我正在构建一个Windows应用商店应用程序,包括图像的本地文件夹.

我想保护所有图像,以便无法访问它们:

C:\Users[username]\AppData\Local\Packages\LocalState\Settings\settings.dat
Run Code Online (Sandbox Code Playgroud)

我知道我应该使用DataProtectionProvider类加密和解密图像,但文档只显示如何加密/解密字符串...

我应该如何将Bitmap图像转换为字节数组?或者我应该用它编码Base64?是否有使用此过程的教程或示例?

c# encryption base64 windows-store-apps windows-8.1

5
推荐指数
0
解决办法
671
查看次数

从MainPage访问UserControl中ItemsSource内的Canvas

我有一个FlipView在我的MainPage.它被ItemTemplate绑定到一个UserControl被叫landscapeControl.它ItemsSource被绑定到一个名为的类的列表 MyLandscape.

landscapeControl:

<Grid>
    <ScrollViewer x:Name="LScrollViewer" MaxZoomFactor="2.0" MinZoomFactor="1.0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" DoubleTapped="LScrollViewer_DoubleTapped" >
        <Canvas x:Name="inkCanvas" Background="Transparent">
            <StackPanel x:Name="LStackPanel" Orientation="Horizontal" Margin="0,0,0,0">
                <Image x:Name="LImage0" HorizontalAlignment="Right" Source="{Binding firstImage}" Width="570"/>
                <Image x:Name="LImage1" HorizontalAlignment="Left"  Source="{Binding nextImage}" Width="570"/>
            </StackPanel>
        </Canvas>
    </ScrollViewer>
</Grid>
Run Code Online (Sandbox Code Playgroud)

MyLandscape 类:

    public class MyLandscape
    {
        public ImageSource firstImage { get; set; }
        public ImageSource nextImage { get; set; }
        public Canvas inkCanvas { get; set; }
    }
Run Code Online (Sandbox Code Playgroud)

我的图像完美呈现.我只想要三件事:

1)我想Canvas从我的访问我 …

c# canvas windows-store-apps windows-8.1

5
推荐指数
0
解决办法
197
查看次数

无法在Xaml中将SelectedIndex ="0"设置为ListView(Windows应用商店应用)

我有2个ListViews和一个TextBlock.第一个ListView1包括按字母顺序排列的字母.第二个ListView2包含以所选字母开头的单词(在ListView1中).当我从ListView1中选择一个字母,然后单击ListView2中加载的单词时,我想在TextBlock中获得该单词的定义.

这是我的Xaml:

<ListView
               Width="510"
               x:Name="ListView1"
               ItemsSource="{Binding}" 
               Background="White"
               Foreground="Black"
               TabIndex="1"
               Margin="-7,8,0,0"
               IsSwipeEnabled="False"

               SelectionChanged="ItemListView_SelectionChanged"
               Grid.Row="1"
               HorizontalAlignment="Left">
               <ListView.ItemTemplate>
                   <DataTemplate>
                       <StackPanel>
                           <TextBlock Grid.Row="0"
                           Text="{Binding glossary_letter}"
            Margin="10,0,0,0" 
            TextWrapping="Wrap"
                           Foreground="Black"
            FontSize="24"
            FontWeight="SemiBold"
            VerticalAlignment="Center"/>
                       </StackPanel>
                   </DataTemplate>
               </ListView.ItemTemplate>
           </ListView>
           <ListView  Width="361"
               x:Name="ListView2"
               Background="White"
               Foreground="Black"
               Margin="425,8,230,0"
               Grid.Row="1"
               HorizontalAlignment="Center"
               ItemsSource="{Binding}"
               SelectionChanged="itemListView2_SelectionChanged">
               <ListView.ItemTemplate>
                   <DataTemplate>
                       <StackPanel>
                           <TextBlock Grid.Row="1"
            TextWrapping="Wrap"
                           Foreground="Black"
                           Text="{Binding}"       
            FontSize="24"
            FontWeight="SemiBold"
            VerticalAlignment="Center"/>
                       </StackPanel>
                   </DataTemplate>
               </ListView.ItemTemplate>
           </ListView>
           <StackPanel HorizontalAlignment="Right"
                       Background="White"
                       Width="580"
                       Margin="0,10,0,0" Grid.Row="1" Grid.ColumnSpan="2">
               <TextBlock x:Name="defBlock" Foreground="Black" Text="{Binding glossary_definition}"></TextBlock>
           </StackPanel>
Run Code Online (Sandbox Code Playgroud)

如果我第一次单击一个字母(ListView1)然后单击一个单词(ListView2),它会显示我的定义.然而,第二次我点击一个字母,它给了我一个OutOfRange错误的地方ListView2.SelectedIndex = -1

这是我的C#代码:

private void ListView1_SelectionChanged(object sender, …
Run Code Online (Sandbox Code Playgroud)

c# xaml listview selectedindex windows-store-apps

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

使用参数导航到VS2015 Windows 10 UWP中的页面

我正在使用Visual Studio 2015和Update 1.我创建了一个带有2个空白页的新UWP Windows 10应用程序.第一页有一个带有itemClick事件的GridView.我绑定到GridViewItem的对象有一个字符串字段"Link",其中包含我将导航到的页面的名称,当单击此GridViewItem时.

private void GridView_ItemClick(object sender, ItemClickEventArgs e)
    {
        var link = (sender as Menu).Link;
        Frame.Navigate(typeof(link));
    }
Run Code Online (Sandbox Code Playgroud)

但这是不可能的......因为这里的"链接"就像一个类型一样使用.有没有办法施展它,并让它工作?

c# navigation visual-studio-2015 windows-10-universal

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