小编Omr*_*ian的帖子

以编程方式在WPF中使用*设置网格列的宽度

我想以编程方式配置wpf网格.

我希望能够设置一个包含2列的网格,第一列占用可用空间的20%,第二列占80%.在xaml中我会使用*运算符,但我无法解决如何以编程方式执行此操作.

在Xaml我会这样做:

<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition width="20*" />
    <ColumnDefinition width="80*" />
</Grid>
Run Code Online (Sandbox Code Playgroud)

在我想要的代码中:

Grid grid = new Grid();
grid.ColumnDefinitions.Add( new ColumnDefinition(20*) );
grid.ColumnDefinitions.Add( new ColumnDefinition(80*) );
Run Code Online (Sandbox Code Playgroud)

请有人建议.

wpf grid

40
推荐指数
3
解决办法
7万
查看次数

Android studio - 无法完成gradle执行 - 打开zip文件时出错

我是android开发和android studio IDE的新手.

我从bitbucket检出了一个项目,当我尝试编译它时,我收到以下错误:

无法完成Gradle执行

原因:打开zip文件时出错.

我的gradle-wrapper.properties情况如下:

distributionBase = GRADLE_USER_HOME
distributionPath = wrapper/dists
zipStoreBase = GRADLE_USER_HOME
zipStorePath = wrapper/dists
distributionUrl = http \://services.gradle.org/distributions/gradle-1.11-all.zip

我无法从此获取太多信息,但完整日志指出:

2014-05-23 14:06:28,950 [32077] WARN - nal.AbstractExternalSystemTask - 原因:打开zip文件时出错com.intellij.openapi.externalSystem.model.ExternalSystemException:原因:在org.jetbrains打开zip文件时出错. plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:206)在org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:116)在org.jetbrains.plugins.gradle. com.intellij.openapi.externalSystem.service.remote上的com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl $ 1.produce(RemoteExternalSystemProjectResolverImpl.java:41)中的service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:64) .RemoteExternalSystemProjectResolverImpl $ 1.produce(RemoteExternalSystemProjectResolverImpl.java:37)at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.jav)一:59)在com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)在com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java: 49)在com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)在com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)在玉米.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)在com.intellij.openapi.externalSystem.util.ExternalSystemUtil $ 3.execute(ExternalSystemUtil.java:467)在com.intellij.openapi. externalSystem.util.ExternalSystemUtil $ 4 $ 2.run(ExternalSystemUtil.java:546)at com.intellij.openapi.progress.impl.ProgressManagerImpl $ TaskRunnabl e.run(ProgressManagerImpl.java:464)在com.intellij.openapi.progress.impl.ProgressManagerImpl $ 2.run(ProgressManagerImpl.java:178)在com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209 )在com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)在com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)在com.intellij.openapi. progress.impl.ProgressManagerImpl $ 8.run(ProgressManagerImpl.java:373)at com.intellij.openapi.application.impl.ApplicationImpl $ 8.run(ApplicationImpl.java:419)at java.util.concurrent.Executors $ RunnableAdapter.call( Executors.java:511)在java.util.concurrent.FutureTask.run(FutureTask.java:266)在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)在java.util.concurrent.ThreadPoolExecutor中的$工人.run(ThreadPoolExecutor.java:617)位于com.intellij.openapi.app的java.lang.Thread.run(Thread.java:745)lication.impl.ApplicationImpl $ 1 $ 1.run(ApplicationImpl.java:149)

2014-05-23 14:06:28,950 [32077] WARN - .project.GradleProjectImporter - 2014-05-23 14:06:28,951 …

java android gradle android-studio android-gradle-plugin

25
推荐指数
3
解决办法
7万
查看次数

WCF服务app.config

我正在开发一个WCF服务,我对它的配置消耗有点困惑.

我的主机应用程序(控制台应用程序)和我的WCF服务项目(随模板附带)中有app.config文件

在运行时,我可以看到使用两个文件的配置.

它是如何工作的?为什么WCF库项目(一个DLL项目)包含一个app.config文件,它的目的是什么?

我真的可以对此进行一些澄清......

更新

这是来自主机应用程序中app.config的WCF配置

<system.serviceModel>

    <!-- services -->
    <services>
        <service name="Services.CalcService">
            <endpoint address="net.tcp://localhost:8412/MyCalcService"
                      binding="netTcpBinding"
                      bindingConfiguration="MyNetTcpBinding"
                      contract="Contracts.ICalc"/>
        </service>
    </services>

    <!-- bindings -->
    <bindings>
        <netTcpBinding>
            <binding name="MyNetTcpBinding"
                     closeTimeout="00:01:00"
                     openTimeout="00:01:00"
                     receiveTimeout="00:10:00"
                     sendTimeout="00:01:00"
                     transactionFlow="false"
                     transferMode="Streamed"
                     transactionProtocol="OleTransactions"
                     hostNameComparisonMode="StrongWildcard"
                     listenBacklog="10"
                     maxBufferPoolSize="524288"
                     maxBufferSize="65536"
                     maxConnections="10"
                     maxReceivedMessageSize="65536">
                <readerQuotas maxDepth="32"
                              maxStringContentLength="8192"
                              maxArrayLength="16384"
                              maxBytesPerRead="4096"
                              maxNameTableCharCount="16384" />
                <reliableSession ordered="true"
                                 inactivityTimeout="00:10:00"
                                 enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                </security>
            </binding>
        </netTcpBinding>
    </bindings>

</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

这是我的WCF服务库中的WCF配置

  <system.serviceModel>
<services>
  <service name="Services.CalcService">
    <endpoint address="" binding="basicHttpBinding" contract="Contracts.ICalc">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint …
Run Code Online (Sandbox Code Playgroud)

c# wcf app-config

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

WPF:在MVVM中创建绑定到未知类型的最佳方法

我正在寻找一种方法来显示DataGrid编译时未知类型的数据.

我有以下基类

public abstract class Entity
{
    // Some implementation of methods ...
}
Run Code Online (Sandbox Code Playgroud)

在运行时,我加载一个插件DLL并使用反射来获取从中派生的所有类型的列表Entity.例如:

public class A : Entity
{
    public LocalAddress Address{ get; set; }
}

public class B : Entity
{
    public Vendor Vendor { get; set; }

    public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

然后我从DB中检索了他们的实例列表

public IEnumerable<Entity> Entities { get; set; } // A list of instances of type A for example
Run Code Online (Sandbox Code Playgroud)

Entities是DataGrid的ItemsSource,但是什么是我可以将属性绑定到的最佳方式DataGrid?由于属性可能很复杂,我还需要能够绑定到特定路径,例如Address.HomeNum......

澄清 …

c# wpf datagrid mvvm

8
推荐指数
2
解决办法
1364
查看次数

PropertyDescriptor和WPF Binding mechinsm

背景

我正在调查一些代码并遇到一个包含DataGrid一些带有绑定列的xaml :

Binding="{Binding calc_from}" ....
Run Code Online (Sandbox Code Playgroud)

我到处搜索,但没有包含名为的属性的类calc_from.然后我偶然发现了一些PropertyDescriptor课程.我认为这是他们如何使绑定工作,但没有完全理解如何.

什么是PropertyDescriptor有益的?我什么时候想实现自己的CustomTypeDescriptor?它与WPF绑定机制有何关系?

我已经在这个帖子中找到了一个例子,但是如果有人能够对它有所了解,我会很高兴

c# wpf xaml

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

如何在MVVM中实现对话框架构

我正在开发基于PRISM框架(Unity Container)的WPF 4.0-MVVM应用程序.

我想知道在mvvm模式中实现对话框的最佳方法是什么.我打算在我的应用程序中使用很多,所以我想要一些可重用的东西.

c# wpf mvvm

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

如何从代码后面访问数据模板中的控件?

嗨,我有一个MediaElement,DataTemplate但我无法从后面的代码访问它.

我发布下面的xaml代码:

<Grid>
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="605*"/>
    <ColumnDefinition Width="151*"/>
</Grid.ColumnDefinitions>
<GroupBox Header="My Videos" Height="177" VerticalAlignment="Top" Margin="5,320,5,0" Grid.ColumnSpan="2">
    <ListBox x:Name="VideoList" ItemsSource="{Binding Videos }" Width="auto" Height=" auto" Margin="0,0,0,0" Grid.ColumnSpan="2" >
        <DataTemplate x:Name="DTVideos">
            <ListBoxItem Name="lbivid1" BorderThickness="2"  Width="240" Selected="lbivid_Selected" >
                <MediaElement Name="vidList" Height="150" Width="150" Source="{Binding SourceUri}" Position="00:00:05" LoadedBehavior="Pause" ScrubbingEnabled="True"/>
            </ListBoxItem>
        </DataTemplate>
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal" Margin="0,0,0,0"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
    </ListBox>
</GroupBox>     
<GroupBox Header="Preview" Height="320" Width="400" VerticalAlignment="Top" DockPanel.Dock="Left">
    <MediaElement x:Name="videoPreview" HorizontalAlignment="Left" Height="300" VerticalAlignment="Top" Width="388"/>
</GroupBox>
Run Code Online (Sandbox Code Playgroud)

代码背后:

 private void lbivid_Selected(object sender, RoutedEventArgs e)
 { …
Run Code Online (Sandbox Code Playgroud)

c# wpf

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

没有对Task的引用会导致内存泄漏吗?

请考虑以下代码段:

public void Do()
{
   ....
   Task.Delay(5000).ContinueWith(t => DoSomething());
   ....
}
Run Code Online (Sandbox Code Playgroud)

假设该Do方法在Delay任务完成之前完成执行且DoSomething不可取消.

对于Task返回的ContinueWith方法没有维护引用这一事实会导致某种内存泄漏吗?

.net c# memory-leaks task-parallel-library

5
推荐指数
2
解决办法
2855
查看次数

在聚焦之前,离子输入不会更新

我有一个表格连接到模型NgModel如下:

<form #orderForm="ngForm" (ngSubmit)="onSubmit(orderForm)">

<ion-list class="contact_view">

  <ion-item>
      <ion-label stacked>{{ 'ADDRESS_LINE_1' | translate }}</ion-label>
      <ion-input type="text" required placeholder="{{ 'ADDRESS_LINE_1_PLACEHOLDER' | translate }}" clearInput="true" name="addressLineOne" [(ngModel)]="order.addressLineOne"></ion-input>
  </ion-item>

  <ion-item>
      <ion-label stacked>{{ 'ADDRESS_LINE_2' | translate }}</ion-label>
      <ion-input type="text" placeholder="{{ 'ADDRESS_LINE_2_PLACEHOLDER' | translate }}" clearInput="true" name="addressLineTwo" [(ngModel)]="order.addressLineTwo"></ion-input>
  </ion-item>
  .... 
  .... 
  ....
 </ion-list>
 </form>
Run Code Online (Sandbox Code Playgroud)

当我将它用作从视图到模型的一个方向绑定时,这对我来说效果很好.

现在,我希望能够从代码更新输入值,如下所示:

ionViewDidEnter() {
    // attempt to load order from memory
    this.storageService
    .get<Order>(StorageKeys.ShippingDetails)
    .then(order => {
        // if order was loaded
        if (order) {
            // test
            this.order.addressLineOne = "aaaa"; // …
Run Code Online (Sandbox Code Playgroud)

ionic-framework ionic2 angular2-forms ionic3

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

DataGrid中的VirtualizingPanel

我最近开始探索WPF中的数据和UI虚拟化功能,偶然发现了一些奇怪的东西.

我创建了一个DataGrid"s的Virtualizing启用和一个有1,000,000项的列表填充它.这种方法效果非常好而且速度惊人.

<Grid>
    <DataGrid x:Name="employees" VirtualizingPanel.IsVirtualizing="True" 
                                 VirtualizingPanel.IsContainerVirtualizable="True"
                                 VirtualizingPanel.VirtualizationMode="Recycling"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)

但是,当我把它嵌入它下载StackPanel超过一分钟直到我得到OutOfMemoryException.我也设置了相同的VirtualizingPanel属性,StackPanel但它没有帮助.

这种行为是故意还是我错过了一些基本的东西?我如何设法在嵌套控件中支持数据虚拟化?

c# wpf datagrid stackpanel virtualizingstackpanel

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