Hi all,
see attachment.
in The Main window I can place a button, but I cannot add an event handler....
I Use custom chrome to remove the window borders but keep the resize option.
Also when I uncomment Initialisecomponents() I get a compile error
where do I go wrong.
Regards,
Ger
The problem is the class name in the xaml file doesn't include the namespace that is in the code behind.
You have:
Code:
x:Class="MainWindow"
instead of
Code:
x:Class="Shader.MainWindow"
You have several options to add a button handler, one is to press the space bar after clicking in a space inside the button declaration in the xaml file. When you press the spacebar, the intelli-sense will give you a list of items to choose from. Choose the Click item and then press the TAB key add a handler in the code behind.
the xaml and code behind should end up as:
Code:
<Button x:
private void CloseWindow_Click(object sender, RoutedEventArgs e)
{
}
Now keep in mind that this is the simple way to add a handler, but in WPF you probably really want to learn the MV-VM approach and use command bindings. You can get a great introduction to MV-VM pattern here:
But honestly, learning WPF isn't something you can poke around in and pick up (or pick up correctly as you've found out). I'd suggest getting a book on WPF or at least spend time doing some online tutorials.
One thing to understand is the editor in VS for WPF is like going back in time as compared to the WinForms editor. If you expect that experience, then you will be disappointed. On the other hand, once you understand WPF, you will find its binding features and customization abilities to be way ahead than WinForms (so it's lack of great editor support isn't going to matter much).
x:Class="MainWindow"
x:Class="Shader.MainWindow"
<Button x:
private void CloseWindow_Click(object sender, RoutedEventArgs e)
{
}
My Code Guru Articles
Hi Arjay,
Long time on 'see' !!
Thanks for the info will have a go.
have some training video's on the subject.
regards,
ger
@Arjay,
The namespace issue did the trick, everything is working as it should.
But there is one little thing 'missing'.
The Dropshadow is not avail anymore, I'm unable to draw outside the window/client region.
So How can I make the drop shadow visible again? It can be done see the windows of VS2012 and outlook 2013.
Regards,
Ger
Originally Posted by TBBW
The Dropshadow is not avail anymore, I'm unable to draw outside the window/client region.
So How can I make the drop shadow visible again?
If you started out with the drop shadow, what did you do to make it go away? Perhaps you removed it when you changed the code that caused the full namespace to change?
@Arjay,
I do the custom window step by step.
I wanted a resizeable window and dragable without the standard windows borders.
It can be done with 9 routines. 1 for dragging and 8 for the resize that is 4 for the sides and 4 for the corners.
But that is like inventing the wheel, so with the use of the shell lib. we can achieve this.
So the next step is to implement the dropshadow or Glow, which one does not matter.
Just like the standard windows have.
If I add a dropshadow to the window in design view (blend) I can see it, as soon as I run the the app, it is gone.
If I look at the 'rules' of xaml windows I see that I'm not allowed to draw outside the client area.
But like the resize issue, there has to be a way, as office is using it. VS2012 and the game installer from Steam usses it.
The big question is what is the 'magic call'.
Most publications on XAML and/or WPF, if not all, do not cover this. As it is beyond scope
Regards,
ger
Forum Rules