我有一个 WPF 应用程序,其中有此用户控件
看法
<Grid Background="{StaticResource ResourceKey=baground}" >
<DockPanel >
<UserControl x:Name="container" ></UserControl>
</DockPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)
我需要添加一个在内容container更改时引发的事件:
private void container_LayoutUpdated_1(object sender, EventArgs e)
{
Thread windowThread2 = new Thread(delegate() { verifing2(); });
windowThread2.SetApartmentState(ApartmentState.STA);
windowThread2.IsBackground = true;
windowThread2.Start();
Thread windowThread3 = new Thread(delegate() { verifing3(); });
windowThread3.SetApartmentState(ApartmentState.STA);
windowThread3.IsBackground = true;
windowThread3.Start();
}
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我尝试了这个活动LayoutUpdated,但我认为这不是最好的主意,因为它被提出了很多次,即使container内容没有改变。
谢谢,
我想了解Environment.FailFastc#应用程序中的规则.所以,我做了这个代码:
public static void Main()
{
string strInput = GetString();
Console.WriteLine(strInput);
Console.ReadKey();
}
private static string GetString()
{
Console.WriteLine("Get string");
string s = Console.ReadLine();
try
{
if (s == "Exit")
{
Environment.FailFast("Erreur fatale");
return s;
}
else
{
return s;
}
}
catch (Exception)
{
return "catch";
}
finally
{
s += "finally";
}
}
Run Code Online (Sandbox Code Playgroud)
据我所知,消息被写入,Windows application event log应用程序终止.
当我运行应用程序并将其Exit作为字符串放置时:


我不明白为什么应用程序没有抛出异常而没有关闭?对于第二点,我如何在PC中找到日志文件?
我需要在wpf mvvm应用程序中的有界组合框中添加一个空项目,我试过这个
<ComboBox TabIndex="23" Text="{Binding Specialisation}" DisplayMemberPath="refsp_libelle">
<ComboBox.ItemsSource>
<CompositeCollection >
<ComboBoxItem > </ComboBoxItem>
<CollectionContainer Collection="{Binding SpecialisationItemSource}" ></CollectionContainer>
</CompositeCollection>
</ComboBox.ItemsSource>
</ComboBox>
Run Code Online (Sandbox Code Playgroud)
它在我尝试添加空项目之前有效.
<ComboBox TabIndex="23" Text="{Binding Specialisation}" ItemsSource="{Binding SpecialisationItemSource}" DisplayMemberPath="refsp_libelle"/>
Run Code Online (Sandbox Code Playgroud)
所以我需要知道:
谢谢,
我试图从MYSQL读取和下载BLOB.虽然记录存在,但我仍然继续得到这个错误.以下是我的代码:
this.Time = String.Format("{0:HH:mm:ss}", DropDownList1.SelectedValue);
String query = "Select * from event where time='" + this.Time + "'";
MySqlConnection conn = new MySqlConnection(connection);
MySqlCommand cmd = new MySqlCommand(query, conn);
String time = String.Format("{0:t}", DateTime.Today);
conn.Open();
MySqlDataReader r = cmd.ExecuteReader();
while (r.Read())
{
TextBox1.Text = r["name"].ToString();
TextBox2.Text = r["Proposedby"].ToString();
bytes = (byte[])r["proposalDoc"];
TextBox5.Text = Calendar1.SelectedDate.ToString("d");
TextBox6.Text = r["time"].ToString();
TextBox7.Text = r["Society"].ToString();
TextBox8.Text = r["venue"].ToString();
}
Run Code Online (Sandbox Code Playgroud)
请告诉我如何消除这个错误.
我有一个wpf应用程序,我将此属性绑定到一个datepicker
public Nullable<System.DateTime> dpc_date_engagement { get; set; }
Run Code Online (Sandbox Code Playgroud)
所以我添加了一个转换器:
public class DateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
return ((DateTime)value).ToShortDateString();
return String.Empty;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
string strValue = value.ToString();
DateTime resultDateTime;
return DateTime.TryParse(strValue, out resultDateTime) ? resultDateTime : value;
}
}
Run Code Online (Sandbox Code Playgroud)
在XAML文件中:
<DatePicker >
<DatePicker.Text>
<Binding Path="dpc_date_engagement" UpdateSourceTrigger="PropertyChanged">
<Binding.Converter>
<converter:DateConverter/>
</Binding.Converter>
</Binding>
</DatePicker.Text>
</DatePicker>
Run Code Online (Sandbox Code Playgroud)
问题是当日期为空时,显示的文本为1/1/0001.
我正在使用MVVM灯和它的Ioc做一个wpf应用程序SimpleIoc.
我实现了这样的存储库模式:
public interface ICrud<T> where T : class
{
IEnumerable<T> GetAll();
Task<IEnumerable<T>> AsyncGetAll();
void AddNew(params T[] items);
void Delete(params T[] items);
void Update(params T[] items);
void SaveOrUpdate(params T[] items);
}
public class Crud<T> : ICrud<T> where T : class
{
public void AddNew(params T[] items)
{
using (var context = new DataEntities())
{
foreach (T item in items)
{
context.Entry(item).State = System.Data.Entity.EntityState.Added;
}
context.SaveChanges();
}
}
public void Delete(params T[] items)
{
using (var context = new …Run Code Online (Sandbox Code Playgroud) 我有这个片段:
public static void Main()
{
OnComparaison += LePlusPetit;
OnComparaison += LePlusGrand;
Console.WriteLine(OnComparaison(0, 9));
Console.ReadKey();
}
public static int LePlusPetit(object obj1, object obj2)
{
int int1 = (int)obj1;
int int2 = (int)obj2;
return (int1 < int2) ? int1 : int2;
}
public static int LePlusGrand(object obj1, object obj2)
{
int int1 = (int)obj1;
int int2 = (int)obj2;
return (int1 > int2) ? int1 : int2;
}
public delegate int Comparer(object obj1, object obj2);
public static event Comparer OnComparaison;
Run Code Online (Sandbox Code Playgroud)
我一直都是这样的结果9 …
我需要在两种技术之间进行比较:使用泛型类型和扩展类型.我不是指一般的比较,我的意思是在这种特殊情况下我需要为一个名为类的类添加一些功能ClassA
使用泛型类型
使用泛型类型(Where T: ClassA)并实现泛型方法
使用扩展方法
使用ClassA添加其扩展方法
public static class Helper
{
public static void MethodOne(this ClassA obj, )
{
//
}
}
Run Code Online (Sandbox Code Playgroud)我需要知道 :
Repository Pattern?例如,在此实现中,为什么我们不向全局类添加扩展方法Entity?我有这个观点:
<div id="addDisplay" class="display">
<div class="box-header">
<h3 class="box-title">Ajouter un compte</h3>
</div>
@{
AjaxOptions addAjaxOpts = new AjaxOptions
{
// options will go here
OnSuccess = "getData",
OnFailure="selectView('add')",
HttpMethod = "Post",
Url = "/api/AccountManage/CreateAccount"
};
}
@using (Ajax.BeginForm(addAjaxOpts))
{
@Html.Hidden("id", 0)
<p>
<label>Statut social </label>
<select id="marital_status" name="marital_status">
<option value="Mr">Monsieur</option>
<option value="MLLE">Mademoiselle</option>
<option value="MME">Madame</option>
</select>
</p>
<p><label>Nom </label>@Html.Editor("Nom")<label style="color:red" id="labError"> ( * )</label></p>
<p><label>Prenom </label>@Html.Editor("Prenom")<label style="color:red" id="labError"> ( * )</label></p>
<p><label>Adresse </label>@Html.TextArea("address")<label style="color:red" id="labError"> ( * )</label></p>
<p><label>Pseudo </label>@Html.Editor("Username")<label style="color:red" id="labError"> …Run Code Online (Sandbox Code Playgroud) 我想在我的剃刀视图中添加一个工具提示,如下所示:
@Html.Editor("Password", new { Title = "Doit contenir au moins une lettre majuscule, une minuscule, un chiffre et un caractère spécial" })
Run Code Online (Sandbox Code Playgroud)
它不起作用,如果我只是通过输入html标签更改html帮助器,它的工作原理!
我需要知道 :