小编dav*_*oxy的帖子

为什么我们使用Interface?它只适用于标准化吗?

为什么我们使用Interface?

它只适用于标准化吗?

oop ooad interface

79
推荐指数
3
解决办法
5万
查看次数

将项添加到WPF ListView中的列

我现在一直在努力将项目添加到2列中ListView.在我的Windows窗体应用程序中,我有这样的事情:

// In my class library:
public void AddItems(ListView listView)
{
    var item = new ListViewItem {Text = "Some Text for Column 1"};
    item.SubItems.Add("Some Text for Column 2");

    listView.Items.Add(item);
}
Run Code Online (Sandbox Code Playgroud)

然后我会从我这个班级打电话Form.cs.

我怎么能在WPF中这样做?最好,我不想使用大量的XAML.

c# wpf xaml listview visual-studio

33
推荐指数
1
解决办法
11万
查看次数

如果ListView在NestedScrollView中,match_parent不适用于ListView

在我的应用程序中,我正在使用它ListView,它在一个内部NestedScrollView.当我设置heightListView,以match_parent不覆盖整个屏幕.我想要ListView覆盖整个屏幕.

我的XML文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:isScrollContainer="false"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill_vertical"
        android:clipToPadding="false"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:paddingTop="1dp">

        <ListView
            android:id="@+id/list"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:divider="@null" />
        </LinearLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

xml android listview nestedscrollview

10
推荐指数
2
解决办法
6032
查看次数

跨多个控件共享事件处理程序

在用C#编写的Windows窗体应用程序中,我有一堆按钮.当用户的鼠标悬停在按钮上时,我希望按钮的边框发生变化.

目前我有以下多个实例(每个按钮的副本):

private void btnStopServer_MouseEnter(object sender, EventArgs e)
{
    oldColor = btnStopServer.FlatAppearance.BorderColor;
    btnStopServer.FlatAppearance.BorderColor = mouseOverColor;
}

private void btnStopServer_MouseLeave(object sender, EventArgs e)
{
    btnStopServer.FlatAppearance.BorderColor = oldColor;
}
Run Code Online (Sandbox Code Playgroud)

由于我有很多按钮,更改按钮边框颜色的代码占用了大量空间.

有没有更简单的方法可以做到这一点?

c# optimization button event-handling winforms

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

如何使网格列表中的每一行都具有相同数量的项目(使用 Flexbox)?

我使用以下 CSS(带有Flexbox)也实现了下面第一张图片中看到的网格列表:

display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
flex-direction: row;
Run Code Online (Sandbox Code Playgroud)

问题是,我想摊开在列表中的项目。更具体地说,我希望每一行都具有相同数量的 items。在下面的第一张图片的情况下,我希望将万事达卡项目移动到第二行,如第二张图片所示。

它目前看起来像这样:

在此处输入图片说明

这是我想要的样子:

在此处输入图片说明

由于容器的大小可以改变,我不能只改变边距(我这样做是为了生成第二个图像)。

这是一个示例:(或者带有前缀JS Bin

display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
flex-direction: row;
Run Code Online (Sandbox Code Playgroud)
#container {
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;
  flex-direction: row;
  display: flex;
  
  width: 450px;
  height: 130px;
  border: 1px solid #8BC34A;
  -webkit-align-self: center;
}

.item {
  justify-content: center;
  margin: 5px;
  display: inline-flex;
  width: 100px;
  height: 50px;
  background-color: #03A9F4;
} …
Run Code Online (Sandbox Code Playgroud)

html css layout flexbox

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

BackgroundWorker 中的调用目标引发的异常

我有以下代码:

public void extractZipFile()
{
    if (!System.IO.Directory.Exists(extractDirectory))
        System.IO.Directory.CreateDirectory(extractDirectory);

    BackgroundWorker worker = new BackgroundWorker();
    worker.WorkerReportsProgress = true;
    worker.ProgressChanged += (o, e) =>
    {
        progbarExtract.Value = Convert.ToInt32(e.ProgressPercentage);
    };

    lblExtracting.Text = "Extracting...";
    worker.DoWork += (o, e) =>
    {
        using (ZipFile zip = ZipFile.Read(zipFile))
        {
            int step = Convert.ToInt32(zip.Count / 100.0); 
            int percentComplete = 0; 
            foreach (ZipEntry file in zip)
            {
                file.Extract(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\XBMC Library Importer\\XBMC_Files", ExtractExistingFileAction.OverwriteSilently);
                    percentComplete += step; //When I comment this out I don't get an exception
                    worker.ReportProgress(percentComplete);
            }
        }
    }; …
Run Code Online (Sandbox Code Playgroud)

c# zip backgroundworker winforms dotnetzip

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

具有自定义视图的可折叠工具栏,当滚动发生并被固定时移动(如留声机)

我希望在我的应用程序中实现与以下内容类似的功能,但我希望整个红色区域(下面的屏幕截图中的"Guardians Of The Gala ...")是自定义视图.(当工具栏折叠时,某些元素会淡出.)

`` `

我一直在努力工作几个小时,但无济于事.

显然,只是把它放入<Toolbar>不起作用,因为它不知道它应该动画它:

<android.support.design.widget.CoordinatorLayout>
    <android.support.design.widget.AppBarLayout>
        <android.support.design.widget.CollapsingToolbarLayout>
            <ImageView/>
            <android.support.v7.widget.Toolbar>
                <include layout="@layout/link_view_title_bar"/>
Run Code Online (Sandbox Code Playgroud)

我已尝试从这里这里做大部分答案,但实际上没有任何效果.

我怎么能这样做,最好主要使用XML和Android设计支持库.任何帮助都会被贬低.

android android-layout material-design android-toolbar android-design-library

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