小编jsa*_*ics的帖子

用于翻页的WPF动画创意

我需要一个想法如何做以下动画的想法.让我们假设我有一个定义如此的视图模型:

public interface IMyViewModel
{
   IPage CurrentPage { get; set;}
}

public interface IPage
{
   string Title { get; set; }
   string Description { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

IPage对象,显然讲,与标题和写入在其上的描述一张纸.当IPage我的视图模型中的对象发生变化时,我希望有一个动画,如下所示: 动画大纲

纸应旋转180°.在旋转90°的阶段,我需要更新显示的内容.

我的视图模型可以实现吗?那有什么好的WPF技巧吗?

.net c# wpf animation xaml

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

如何使用C#基于条件更改gridview单元格颜色

我想根据条件更改grdiview单元格的颜色,条件是如果Passport即将在一个月内过期或者它已经过期,那么我想检查这两个条件是否会过期或者是否已经过期过期然后我想把颜色变成红色.谢谢

protected void OnRowDataBound_gvPass(object sender, GridViewRowEventArgs e)
    {
      DateTime todaysDate = DateTime.Now.Date;
      if (e.Row.RowType == DataControlRowType.DataRow)
      {


        Label lblPassportExpDate = (Label)e.Row.FindControl("PassportExpDate");
        DateTime PassportExpDateDate = DateTime.Parse(lblPassportExpDate.Text);
        if (PassportExpDateDate < DateTime.Today || PassportExpDateDate < todaysDate.AddDays(30))
        {
          //e.Row.BackColor = System.Drawing.Color.Red;
          gvDriverStatus.Columns[3].ItemStyle.ForeColor = System.Drawing.Color.Red;
        }

      }
    }
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net gridview

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

WCF:提供的URI方案"https"无效; 预计'http'.参数名称:当我调用IInternal proxy = factory.CreateChannel()时的via; 在客户端

服务器的App.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="NewBehaviour">
          <serviceMetadata httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="Binding">
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

    <services>
      <service name="Server.InternalClass" behaviorConfiguration="NewBehaviour">
        <endpoint address="IInternal" binding="wsHttpBinding" bindingConfiguration="Binding" contract="Common.IInternal">
          <identity>
            <dns value="MyMachine"/>
          </identity>
        </endpoint>
       <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/> 
        <host>
          <baseAddresses>
            <add baseAddress="https://MyMachine:8733/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>


</configuration>
Run Code Online (Sandbox Code Playgroud)

客户

static ChannelFactory<IInternal> factory = new ChannelFactory<IInternal>(new WSHttpBinding(), new EndpointAddress("https://MyMachine:8733/IInternal"));
Run Code Online (Sandbox Code Playgroud)

当我调用方法factory.CreateChannel()时,我得到错误

我配置证书

在此输入图像描述

c# wcf

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

绑定到WPF中的设计数据

我有一个包含ListBox的WPF窗口.ItemsSource绑定到视图模型的属性.

<Window x:Class="SimpleWpfApp.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525"
        DataContext="{Binding MainWindowViewModel, Source={StaticResource Locator}}">
  <DockPanel>
    <ListBox ItemsSource="{Binding SomeThings}" />
  </DockPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)

视图模型的属性是自定义接口的可观察集合; ISomeInterface.界面非常简单,由SomeClass实现,它还会覆盖ToString.

public class MainWindowViewModel
{
  public ObservableCollection<ISomeInterface> SomeThings
  {
    get
    {
      var list = new List<ISomeInterface>
      {
        new SomeClass {Value = "initialised"},
        new SomeClass {Value = "in"},
        new SomeClass {Value = "code"}
      };

      return new ObservableCollection<ISomeInterface>(list);
    }
  }
}

public interface ISomeInterface
{
  string Value { get; }
}

public class SomeClass : ISomeInterface
{
  public string …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml design-data visual-studio-2015

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

Xamarin.Forms ListView在ContextMenu上更改Cell打开

我使用Xamarin.Forms来定义一个ListView.这ListView定义了ContextAction内部的一些内容ViewCell.然后,根据平台,将这些上下文动作呈现给用户.在Android中,这是通过长按特定项目来触发的.可悲的是,这个项目不会(正确地)突出显示,正如在这个截图中可以看到的那样(我长期压下第三项,遗憾的是我还没有嵌入图像).

在此输入图像描述

有没有办法在上下文菜单打开时修改Cell?特别是要求Android的解决方案,但也欢迎一般的答案.目标最终是改善突出显示,例如通过更改单元格的背景颜色.当ContextAction按下一个单元时,修改单元格不是我想要的.

我浏览了Xamarin.Forms的源代码,并考虑以某种方式继承自例如ViewCell类,但找不到长按项目时会触发/调用的事件或命令.我已经设置了一个简单的存储库来说明行为:GitHub存储库

最重要的代码片段

  • XAML中的ListView定义

    <?xml version="1.0" encoding="utf-8"?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:ListViewContextMenu" x:Class="ListViewContextMenu.ListViewContextMenuPage">
        <ListView x:Name="MyListView">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.ContextActions>
                            <MenuItem Text="Action" Command="{Binding OnAction}" CommandParameter="{Binding .}"/>
                        </ViewCell.ContextActions>
                        <Label Text="{Binding Name}" />
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </ContentPage>
    
    Run Code Online (Sandbox Code Playgroud)
  • MyItem定义(MVVM)

    using System.Diagnostics;
    using Xamarin.Forms;
    
    namespace ListViewContextMenu
    {
        public class MyItem
        {
            public string Name { get; set; }
            public Command OnAction { get; set; }
    
            public MyItem()
            {
                OnAction = …
    Run Code Online (Sandbox Code Playgroud)

c# listview listviewitem xamarin.forms

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

对于无符号字节来说,值太大或太小

出现以下错误:

已引发 System.OverflowException - 对于无符号字节,值太大或太小。

有谁知道如何解决它?

class MainClass
{
    public static void Main(string[] args)
    {
            int decValue = 2210;
            string bin = Convert.ToString(decValue, 2);
            string lowerbyte = bin.Substring(Math.Max(0, bin.Length - 16));

            if (lowerbyte.Length < 16)
            {
                lowerbyte = lowerbyte.PadLeft(16, '0');
            }


        Int16 circular = Convert.ToByte(CicrularLeftShift(lowerbyte, 3), 2);

            string xored = Convert.ToString((circular ^ 38556), 2).Substring(Math.Max(0, Convert.ToString((circular ^ 38556), 2).Length - 16));

            //converting final binary shift value to HEX
            string finalHex = Convert.ToString(Convert.ToInt32(xored, 2), 16).ToUpper();

        Console.WriteLine(finalHex);

    }

    private static string CicrularLeftShift(string key, …
Run Code Online (Sandbox Code Playgroud)

c#

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

Google Calendar API v3 显示名称

我从资源日历中检索事件列表。在DisplayName两者的OrganizerCreator始终是空的。我尝试了在线Google 日历 API 参考,该示例也返回一个空值DisplayName。关于如何做到这一点的任何想法?

我正在使用 Google 日历 API v3。谢谢。

api calendar google-calendar-api

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

PieChart不会出现

我需要显示一个PieChart,我目前正在使用Modern UI(Metro)图表.我确实复制了文档中的代码,问题是我总是在屏幕上有边框和标题但没有图表.

XAML

<UserControl x:Class="Projet.Recources0.Statistique.Ad_Aj"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:mui="http://firstfloorsoftware.com/ModernUI"
         xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
         xmlns:chart="clr-namespace:De.TorstenMandelkow.MetroChart;assembly=De.TorstenMandelkow.MetroChart"
         mc:Ignorable="d" d:DesignWidth="1000" Height="670">

<UserControl.Resources>
    <Style x:Key="MinimalChartStyle" TargetType="{x:Type chart:ChartBase}">
        <Setter Property="Width" Value="500"/>
        <Setter Property="Height" Value="500"/>            
    </Style>
</UserControl.Resources>
<Grid >
    <chart:PieChart
    Style="{StaticResource MinimalChartStyle}"
    ChartTitle="Minimal Pie Chart"
    ChartSubTitle="Chart with fixed width and height"
    SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay}" >
        <chart:PieChart.Series>
            <chart:ChartSeries
            SeriesTitle="Errors"
            DisplayMember="Category"
            ValueMember="Number"
            ItemsSource="{Binding Path=Errors}" />
        </chart:PieChart.Series>
    </chart:PieChart>
</Grid>
Run Code Online (Sandbox Code Playgroud)

CS

using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows; …
Run Code Online (Sandbox Code Playgroud)

c# wpf charts xaml

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

如何在ASP.NET中显示多系列柱形图

在我的Web应用程序中,我需要显示从数据表绑定的柱形图数据,我在我的统计图区域中的X轴上有3列,我需要在一侧显示col1,在第二列显示,并且需要为系列显示图例显示不同的颜色也来自数据表。

我需要像这样的我该怎么做,请任何人都可以帮助我该怎么做。

谢谢

.net c# asp.net data-visualization mschart

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

使用 OpenXML 将图像添加到 Word 文档

我开发了一个应用程序,该应用程序应该将图像添加到Word文档中。它从 Word 文档中获取副本并将图片添加到副本中。我尝试添加文本,效果很好,但是通过添加图像,word 文档想要打开一个文件,并给出错误(无法打开文件“名称”,因为内容存在问题。)

我的代码如下所示:

File.Copy(file, newFile, true);
     WordprocessingDocument wordFile = WordprocessingDocument.Open(newFile, true);
     Body body = wordFile.MainDocumentPart.Document.Body;

     var picture = new Picture();
     var shape = new Shape() { Style = "width: 20px; height: 20px" };
     var imageData = new ImageData() { RelationshipId = "img" };

     shape.Append(imageData);
     picture.Append(shape);
     wordFile.MainDocumentPart.AddExternalRelationship(
          "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
           new Uri(link_of_image, UriKind.Absolute),"img");

     Paragraph para = body.AppendChild(new Paragraph());
     Run run = para.AppendChild(new Run());
     run.AppendChild(new Picture(picture));

     wordFile.Close();
Run Code Online (Sandbox Code Playgroud)

可能出什么问题了?

c# openxml

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