.net-4.0

Set button content on button click trigger in xaml

你离开我真会死。 提交于 2019-12-06 02:13:44
问题 I would like to set button content using trigger in XAML without writing code behind: Every time button is clicked, content should be changed: Something like button clicked first time, button content = "Hi", Second time clicked, button content = "Bye", Third time clicked, button content = "Hi" again. <Button x:Name="btn" Content="Hi"> <Button.Triggers> <EventTrigger RoutedEvent="Button.Click"> <BeginStoryboard> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.Target="{x:Reference btn}"

Use classes from another MEF assembly without referencing to it

╄→尐↘猪︶ㄣ 提交于 2019-12-06 02:03:05
I have 2 MEF components. Let it be component A and component B. What I need is to be able to access a class from component B in component A without referencing to it. Then I would like to instantiate object of the class manually. Currently I see MEF allows instantiating an object automatically using [Import]. It uses interface which requires to be referenced to. Can I use data types from another assemblies without referencing to it? Is there such mechanism supported by MEF? There are a couple of ways to do this. First, you need to define a common interface that both assemblies understand. This

nunit on release build: “Common Language Runtime detected an invalid program.”

我怕爱的太早我们不能终老 提交于 2019-12-06 01:59:37
问题 I upgraded our software from vs2008/.net 3.5 to vs2010/.net 4.0. All third party libraries (most relevant: nhibernate 2.1.2 or 3.0.0, nunit 2.5.2) are still compiled using vs2008. When I run the unit tests for the debug build of our software, everything works fine. On the release build, nunit reports exceptions on 33 of 228 tests: System.InvalidProgramException : Common Language Runtime detected an invalid program. It always happens on the same tests, for both nunit-console and the Resharper

WPF Binding Path=/ not working?

谁说我不能喝 提交于 2019-12-06 01:57:28
I've set up my DataContext like this: <Window.DataContext> <c:DownloadManager /> </Window.DataContext> Where DownloadManager is Enumerable<DownloadItem> . Then I set my DataGrid like this: <DataGrid Name="dataGrid1" ItemsSource="{Binding Path=/}" ... So that it should list all the DownloadItems, right? So I should be able to set my columns like: <DataGridTextColumn Binding="{Binding Path=Uri, Mode=OneWay}" Where Uri is a property of the DownloadItem . But it doesn't seem to like this. In the visual property editor, it doesn't recognize Uri is a valid property, so I'm guessing I'm doing

Triggered Content Template

喜夏-厌秋 提交于 2019-12-06 01:52:26
I'm trying to set up a ContentTemplate that changes based on a DataTrigger. Syntatically, I feel like this should work, but it results in a stack overflow when trying to render the page: <ItemsControl ItemsSource="{Binding Path=ExtendedFieldCollection}" ItemTemplate="{StaticResource RequiredFieldsTemplate}" /> <!--Where--> <DataTemplate x:Key="RequiredFieldsTemplate"> <ContentPresenter> <ContentPresenter.Style> <Style TargetType="ContentPresenter"> <Setter Property="ContentTemplate" Value="{x:Null}"/> <Style.Triggers> <DataTrigger Binding="{Binding IsRequired}" Value="True"> <Setter Property=

What happens when a Task is running and it's window is closed?

亡梦爱人 提交于 2019-12-06 01:47:55
问题 In my WPF Window_Loaded event handler I have something like this: System.Threading.Tasks.Task.Factory.StartNew(() => { // load data from database this.Dispatcher.Invoke((Action)delegate { // update UI with loaded data }); }); What I want to know is what happens when the user closes the form while data is being loaded from the database and before the this.Dispatcher.Invoke routine is ran? Will there be an ObjectDisposedException thrown? Or will the Dispatcher ignore the Invoke routine (as the

asp.net add custom control in website

Deadly 提交于 2019-12-06 01:37:54
I want to make a custom control in my website (note: not web application) Following is the code using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel; using System.Web.UI; using System.Web.UI.WebControls; namespace AnkitControls { /// <summary> /// Summary description for CustomTreeView /// </summary> public class CustomTreeViewControl : WebControl { } } Default.aspx : <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly=

CLR String References Don't (Always) Match

笑着哭i 提交于 2019-12-06 01:24:59
From Richter and this discussion , I would expect any two "identical" strings to be the same reference. But just now in LINQPad I got mixed results on this topic. Here is the code: void Main() { string alpha = String.Format("Hello{0}", 5); string brava = String.Format("Hello{0}", 5); ReferenceEquals(alpha, brava).Dump(); String.IsInterned(alpha).Dump(); String.IsInterned(brava).Dump(); alpha = "hello"; brava = "hello"; ReferenceEquals(alpha, brava).Dump(); } And here are the results from the Dump() calls: False Hello5 Hello5 True I would have expected both the first and last ReferenceEquals to

Downgrade code of HttpClient .NET 4.5 to .NET 4.0

大兔子大兔子 提交于 2019-12-06 01:05:42
问题 I have this code that is working fine in .NET 4.5. var handler = new HttpClientHandler(); handler.UseDefaultCredentials = true; handler.PreAuthenticate = true; handler.ClientCertificateOptions = ClientCertificateOption.Automatic; var client = new HttpClient(handler); client.BaseAddress = new Uri("http://localhost:22678/"); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var loginBindingModel = new LoginBindingModel { Password = "test01",

Can't add .NET 4.0 Assembly Reference In MonoDevelop 2.4.1

只愿长相守 提交于 2019-12-06 01:00:02
问题 I've installed MonoDevelop 2.4.1 With Mono 2.8.1. My trouble is that i can't add assembly reference to assembly compiled for .NET 4.0 (on same MonoDevelop IDE). What am i do. References -> Edit References -> .NET Assembly -> Browse to file & select it Than MD displays an error that an assembly that i'm trying to add isn't .NET assembly. I've set profile to .NET 4.0 everywhere. Reflector disassembles my assembly fine so it's ok. My OS is Windows 7 What's wrong? UPD: Posted a bug to Novell.