It's the "Loaded" event.
void MyUserControl_Loaded(object sender, RoutedEventArgs e)
{
}
To set up the event handler, you can use
this.Loaded += MyUserControl_Loaded
in code behind, or
Loaded="MyUserControl_Loaded"
in XAML
It's the "Loaded" event.
void MyUserControl_Loaded(object sender, RoutedEventArgs e)
{
}
To set up the event handler, you can use
this.Loaded += MyUserControl_Loaded
in code behind, or
Loaded="MyUserControl_Loaded"
in XAML
I'm not really an XPath expert, but my guess would be: //System[1]/Kind
You can select an item by using the XPath expression. Instead of XPath=//Kind, use XPath=//Kind[0], or XPath=//Kind[1], etc.
The best way to do this is to create an interface that encapsulates the common properties of your entities:
public interface IEntity
{
string SomeProperty { get; set; }
}
public interface IAnotherInterface
{
string Name { get; set; }
}
Each entity can inherit multiple interfaces, depending on how you want it set up:
public class Entity1 : IEntity, IAnotherInterface
{
public string SomeProperty { get; set; }
public string Name { get; set; }
}
If every entity has a certain interface, then you can require it in the Form definition:
public partial class Form1 : Form
where T : IEntity
Finally, cast to the interfaces to set properties. If only some entities implement a given interface, check first.
void SetSomeProperties()
{
(entity as IEntity).SomeProperty = "foo";
if (entity is IAnotherInterface)
{
(entity as IAnotherInterface).Name = "bar";
}
}
I think I see what the problem is. In the ListBox XAML, you don't need the Source=data (that's incorrect syntax, and besides, you already set the DataContext from the code-behind, so it's not needed. Take that part out, and it should work:
That's an interesting point, but I'm not sure how it's relevant to the question (remember, this relates to a C# console app).
Right, of course, but my point is that it's far better to interact with an API, than trying to parse the output from a console application.
I think it would be better to reorganize your code. The console project you wrote really should be a library/API, if you're going to consume it from another application (ie, the windows service). I'd suggest converting your console application into a class library project. Then, both the windows service and console can create their own implementations. So, let's say you execute the console app like this: myconsoleapp.exe "servicename" Then, create a library project with a public method "RunService":
public class MyAPI
{
public string ExecuteService(string serviceName)
{
// logic goes here
}
}
Now both the console app, and your new windows service can consume MyAPI as needed.