Things that can be useful every now and then.
1 Determine calendar week of a date.
private int KW(DateTime_datum)
{
CultureInfo cultureInfo = CultureInfo.CurrentCulture;
}int kw = cultureInfo.Calendar.GetWeekOfYear (date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
{return kw;
}2. Create simple event.
public event EventHandler < EventArgs > DeletePersonEvent;
private void DeletePerson()
{
if(DeletePersonEvent_!=_null)
{
DeletePersonEvent(this,_new_EventArgs());_
)}
}3. WPF line break in a caption or text tag.
< text x: name = "myTextBox" text = "line 1 & # x0a;" Line 2 "/ >
Line break with: & # x0a;
4. DataTable via WCF
This is not possible. You may Pack it first in a DataSet and then transferred via WCF.
public DataSet GetPersonenDataSet()
{
DataSet ds = new dataset();
}DS.Tables.Add(m_PersonDao.Read());
{return ds;
}m_PersonDao.Read() returns a DataTable.
5. WPF data binding
Also always something I look for, though it is actually very simple.
Probably ways how you can solve it around 1000. I am doing so at the time.
Code-behind of the XAML:
public RaumView(RaumModel_model)
{
InitializeComponent();
}this. m_Model model; =
this.{DataContext = m_Model;
}In line 7, I tie a class that contains my objects to the DataContext.
Then, I can easily bind the data to the controls.
Text = "{binding Raum.Standort.Bezeichnung, mode = OneWay}"M_Model.Raum.Standort.Bezeichnung actually appears in this text. The field synchronizes but not back in the DataContext (mode = OneWay). If that the case should be then to do so.
Text = "{binding Raum.Bezeichnung, Mode = TwoWay}"The name of the room is now synchronized back to the DataContext (mode = "TwoWay").
So roughly it is sufficient at the moment for me.
6. GUID change in the debugger
The need has a variable at run time to change, which is of type GUID man times you can not just say the new GUID in the debugger.
So, it looks at run time.
Easily add new GUID between the {} copy results in an error.
Solution:
new GUID (< GUID >)
So it looks.
7. Any file open
I want to open a file without that I need to know the program that is needed for the file. This is of course only if a trader on the system file is registered. And if, then it's easy.
Process process.start("Notepad.exe") = new Process();
myProcess.StartInfo.FileName = < PFAD_ZUR_DATEI >;
myProcess.StartInfo.UseShellExecute = true;
myProcess.StartInfo.RedirectStandardOutput = false;
myProcess.Start();The file name must be a full path to its file. for example: "c:\temp\MeinProgi\MeineDatei.txt"
8. Program open an email with the standard email.
Also this can be done with the process class.
Process process.start("Notepad.exe") = new Process();
myProcess.StartInfo.FileName = String.Format("mailto:{0}",_mailto);
myProcess.StartInfo.UseShellExecute = true;
myProcess.StartInfo.RedirectStandardOutput = false;
myProcess.Start();And already an E-Mail with his default email program will open. But this is only if a mailto trader is registered on the system. But as soon as an email client is installed that is the case. If there is no mailto dealer can passing strange. With us on a Windows XP Internet Explorer started a few then 100 times. How so he started so often is not clear to me. But then there was a click orgy until all IE's were closed.
The mailto dealer can be found under HKEY_CLASSES_ROOT\mailto . This means that there must be something in the form of HKEY_CLASSES_ROOT\mailto\shell\open\command with an entry.
So, you can open a URL with the default browser. Then it specifies only the URL with file name . http://…
9. WCF classes and their constructors
I wanted to force a value in the initialization of a new class. It should always be set. To do this I have overloaded the constructor simply means more empty not offered.
Then the host wanted to no longer start. But the error message gave no indication. There was also no reference to find in the Tracelogs of the WCF. By chance I've got then sent set and there the note a breakpoint that the class series cannot be serialized. Because made it click.
You realize that. Classes that are to be transferred through WCF must have a default constructor without overload.
10. WPF Dantenbindung between controls properties
Well, if the title fits here? We look at times.
I'm always times again to the situation which I should controls turn on or turn off, and that on the basis of other controls. E.G. If IsChecked = true radio button, then you are displayed. This is also surprisingly simple with WPF.
IsEnabled = {binding ElementName = optMamUnten, path = IsChecked}Binding element name are on what control you want to use. With path is said then still on which property you want to pay attention. Once the radio button with the name is optMamUnten IsChecked = true , the control is turned on. It can be so simple.
Then gives a very beautiful and simply implemented effect.

