为简单起见,我有以下缩写
<ItemsControl ItemSource="{Binding enumerableList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding displayName, Mode=OneWay}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到它以便我的TextBox在绑定到它的文本前面显示一个子弹点?所需格式:
我有一个简单的XAML页面,其上有一个像这样定义的ListView
<ListView Margin="10" Name="lvUsers" ItemsSource="{Binding People}">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" Width="120" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Header="Age" Width="50" DisplayMemberBinding="{Binding Age}" />
<GridViewColumn Header="Mail" Width="150" DisplayMemberBinding="{Binding Mail}" />
</GridView>
</ListView.View>
</ListView>
Run Code Online (Sandbox Code Playgroud)
在我做的代码中: -
public ObservableCollection<Person> People { get; set; }
public ListView()
{
InitializeComponent();
this.People = new ObservableCollection<Person>();
this.People.Add(new Person() { Name = "John Doe", Age = 42, Mail = "john@doe-family.com" });
this.People.Add(new Person() { Name = "Jane Doe", Age = 39, Mail = "jane@doe-family.com" });
this.People.Add(new Person() { Name = "Sammy …
Run Code Online (Sandbox Code Playgroud) 对于WPF,数据网格我试图复制到剪贴板我的自定义文本数据,在Ctrl+C
Diverse尝试使用覆盖后,
OnCopyingRowClipboardContent(DataGridRowClipboardEventArgs args)
或CopingRowClipboardContent event
没有帮助.
剪贴板变为空或标准行文本,但不是我想放在那里.例如
protected override void OnCopyingRowClipboardContent(DataGridRowClipboardEventArgs args)
{
Clipboard.SetText("Abc-hello");
bool b1 = Clipboard.ContainsText();
string s1 = Clipboard.GetText();
}
Run Code Online (Sandbox Code Playgroud)
s1
获得所需的文本,但在退出此方法后,剪贴板变空.知道是否可以解决这个问题?
我有以下方法在DataGridView上加载产品
private void LoadProducts(List<Product> products)
{
Source.DataSource = products; // Source is BindingSource
ProductsDataGrid.DataSource = Source;
}
Run Code Online (Sandbox Code Playgroud)
现在我试图让我回来保存它们如下图所示.
private void SaveAll()
{
Repository repository = Repository.Instance;
List<object> products = (List<object>)Source.DataSource;
Console.WriteLine("Este es el número {0}", products.Count);
repository.SaveAll<Product>(products);
notificacionLbl.Visible = false;
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了InvalidCastException
这条线:
List<object> products = (List<object>)Source.DataSource;
Run Code Online (Sandbox Code Playgroud)
那么如何将DataSource转换为List呢?
我尝试了一些选项,但似乎都没有,有些发送错误.
请让我知道我做错了什么
public string Main(String wbPath, String wbName)
{
string cName = "";
Excel.Application xlApp;
Excel.Workbook xlWB;
Excel.Worksheet xlWS;
xlApp = new Excel.Application();
xlApp.DisplayAlerts = false;
xlApp.Calculation = Excel.XlCalculation.xlCalculationManual; //Error occurs here
xlWB = xlApp.Workbooks.Open(wbPath + wbName);
xlWB.SaveAs("vFile.html", Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml);
cName = xlWB.FullName;
xlWB.Close();
xlApp.Quit();
return cName;
}
Run Code Online (Sandbox Code Playgroud)
错误代码:
{"Exception from HRESULT: 0x800A03EC"}
Run Code Online (Sandbox Code Playgroud) 我在viewmodel中有这个属性.
public bool IsKWH
{
get { return _isKwh; }
set
{
if (value.Equals(_isKwh)) return;
_isKwh = value;
NotifyOfPropertyChange(() => IsKWH);
}
}
Run Code Online (Sandbox Code Playgroud)
关闭我的应用程序时,有时候(10次中有~10次)我在NotifyOfPropertyChange中收到以下错误:
WindowsBase.dll中出现"System.Threading.Tasks.TaskCanceledException"类型的异常,但未在用户代码中处理
附加信息:任务已取消.
我在我的视图模型中有一个System.Threading.Timer,它正在进行webservice调用以更新这个和许多其他属性.
我正在使用Caliburn.Micro,当我从1.5更新到2.0时,它似乎已经开始发生.
反正有没有阻止这种错误发生?
我正在开发一个示例Xamarin应用程序,我得到Android配置文件的构建错误,以下是错误.
Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken='.
Perhaps it doesn't exist in the Mono for Android profile? File name: 'Windows.dll' at
Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
Xamarin.Android.Tasks.ResolveAssemblies.Execute()
Run Code Online (Sandbox Code Playgroud)
我无法理解究竟是什么问题,在Android配置文件的单声道中不存在Windows程序集?请帮我.
有没有人完成从wpf转换Pen
为gdi + one的转换?
起初听起来并不复杂:使用带有相应画笔的构造函数.但是有很多小细节:不同的画笔(wpf中有5个,gdi中有5个不同的名称,属性等)以及笔本身.
也许有很多简单的解决方案,比如ToString()
/ Parse()
one或者通过序列化,或者可能是专用方法或隐藏类.不想走多远的if(type is ...)
路.
这是一种可能的方法(演示,可能不起作用)
using System.Windows.Media;
using GDI = System.Drawing;
public static GDI.Pen ToGDI(this Pen pen)
{
var brush = pen.Brush;
var thickness = pen.Thickness;
if(brush is SolidColorBrush)
{
var color = ((SolidColorBrush)brush).Color;
return new GDI.Pen(new GDI.SolidBrush(Colors.FromArgb(color.A, color.R, color.G, color.B)), (float)thickness);
}
else if(brush is ...)
{
...
}
}
Run Code Online (Sandbox Code Playgroud) 我是WPF和XAML的完全新手.
我为文本框创建了一个简单的淡入和淡出动画: -
<Storyboard x:Key="storyFadeInOutTop" Name="storyFadeInOutTop">
<DoubleAnimation From="0" To="1" Duration="00:00:01"
Storyboard.TargetName="txtTopCredit"
Storyboard.TargetProperty="Opacity">
</DoubleAnimation>
<DoubleAnimation From="10" To="0" Duration="00:00:01" BeginTime="00:00:01"
Storyboard.TargetName="blurTop"
Storyboard.TargetProperty="Radius">
</DoubleAnimation>
<DoubleAnimation From="0" To="10" Duration="00:00:01" BeginTime="00:00:05"
Storyboard.TargetName="blurTop"
Storyboard.TargetProperty="Radius">
</DoubleAnimation>
<DoubleAnimation From="1" To="0" Duration="00:00:01" BeginTime="00:00:06"
Storyboard.TargetName="txtTopCredit"
Storyboard.TargetProperty="Opacity">
</DoubleAnimation>
</Storyboard>
Run Code Online (Sandbox Code Playgroud)
我想做的是在动画的生命周期中多次运行这个故事板.
就像是:-
<Storyboard>
<!-- (Run my fade-in-fade out with BeginTime of 00:00:00) -->
<StringAnimationUsingKeyFrames Duration="00:00:01" BeginTime="00:00:07"
Storyboard.TargetName="txtTopCredit"
Storyboard.TargetProperty="Text">
<DiscreteStringKeyFrame Value="Game design and concept by" KeyTime="0:0:1" />
</StringAnimationUsingKeyFrames>
<!-- (Run my fade-in-fade out again with BeginTime of 00:00:07) -->
<StringAnimationUsingKeyFrames Duration="00:00:01" BeginTime="00:00:07"
Storyboard.TargetName="txtTopCredit" …
Run Code Online (Sandbox Code Playgroud) 我有一个实现可绑定基本如下,请看看他们均绑定了两个按钮,在视图中上移和下移方法视图模型的观察的集合.当按下向上按钮时,我希望数据网格中的选定行在数据库中基于序列列向上移动一步并向下移动一步.两种方法都可以完美地工作.问题是只有在刷新整个视图时才会在数据网格中显示更改.我的要求是单击按钮时我希望视图自动刷新.我为这么长的代码道歉.请帮忙!!!!.我在viewmodel下面指定的向上和向下按钮都有一些cs代码.只需要强调的代码中的指针是ObservableCollection JobEntities,MoveUp和MoveDown命令.
ViewModel.cs:
public class JobConfigurationViewModel : BindableBase
{
public JobConfigurationLogic JobConfigurationLogic =
new JobConfigurationLogic(new JobConfigurationResultsRepository());
public SrcDestConfigurationLogic SrcDestConfigurationLogic =
new SrcDestConfigurationLogic(new SrcDestCofigurationRepository());
private string _enterprise;
public string Enterprise
{
get { return _enterprise; }
set { SetProperty(ref _enterprise, value); }
}
private int currentJobID;
private int currentSequence;
private int previousJobID;
private int previousSequence;
private string _site;
public string Site
{
get { return _site; }
set { SetProperty(ref _site, value); }
}
private int _siteID;
public int SiteID
{ …
Run Code Online (Sandbox Code Playgroud) c# ×8
wpf ×7
xaml ×4
winforms ×2
.net ×1
binding ×1
casting ×1
clipboard ×1
data-binding ×1
datagrid ×1
datagridview ×1
datasource ×1
decorator ×1
mono ×1
mvvm ×1
prism ×1
xamarin ×1
xamarin.ios ×1