|
-
Jan 15th, 2009, 09:58 PM
#41
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Code:
Title="Window1" Height="300" Width="300" AllowsTransparency="True" Opacity="0.85" WindowStyle="None">
-
Jan 15th, 2009, 09:58 PM
#42
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
-
Jan 15th, 2009, 10:07 PM
#43
Re: You owe it to yourself to use WPF
Yeah but I dont want to have a windowstyle of "none" - I dont see how VB.NET can make windows transparent easily enough but the great graphical user interface product WPF cannot :S
Anyway I'm going to bed now, I have to be at work in 5 hours
-
Jan 16th, 2009, 08:20 AM
#44
Re: You owe it to yourself to use WPF
Just noticed a link to this article at the top of the forums
http://www.devx.com/dotnet/Article/4...k=DXRSS_DOTNET
Quite good for people like myself who are pretty new to the whole WPF thing
-
Jan 16th, 2009, 09:09 AM
#45
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Hey man, ok I think the difference in the transparency is because WPF is true transparency where as Winforms is only pseudo transparency, il find out more later. PS good article, im going to put that in my sig, it will save me writing one up. Also dont panic im only a beginner too! I just have a head start!
-
Jan 16th, 2009, 09:32 AM
#46
Re: You owe it to yourself to use WPF
One feature I played with recently was with the templates concept.... puts a whole new spin on things... I was able to make a list box.... the standard WPF listbox... contain multi-lined items, with a blue header for the first line and rounded corners.... If I had thought about it sooner I would have grabbed the sample from home to post it. It was pretty cool and surprisingly easy to do. And didn't require all sorts of inheriting and subclassing and ownerdrawn this and ownerdrawn that.... jsut some simple XAML tags and attributes.
-tg
-
Jan 16th, 2009, 09:34 AM
#47
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Yeah its pretty funky, im working on a validation text box who's border will "pulse" red if the data is incorrect. with rounded corners too! I lover rounded conrners! Everything should have rounded corners!
-
Jan 16th, 2009, 09:41 AM
#48
Re: You owe it to yourself to use WPF
I love rounded corners too... three cheers for rounded corners!
PS how do you make them in WPF?
-
Jan 16th, 2009, 10:36 AM
#49
Re: You owe it to yourself to use WPF
I'd say that I'll look for the code tonight, but it's the wife's bday and we're going out. If I remember tomorrow or in the middle of the night, I'll post it.
But it wasnt' that hard... takes like three attribute properties, a color, a margin and a style, if I remember right.
look in the WPF How To video section on MSDN... I think that's where I got it from.
-tg
-
Jan 16th, 2009, 10:56 AM
#50
Re: You owe it to yourself to use WPF
cool I will take a look at the WPF vids
-
Jan 16th, 2009, 04:27 PM
#51
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Chris, how are you getting on? I cant do a lot of coding until monday unfortunately but I have been playing with silverlight. Are you a convert yet?
-
Jan 17th, 2009, 02:27 AM
#52
Re: You owe it to yourself to use WPF
 Originally Posted by chris128
I agree, I just personally dont see why the UI needs to be separated from the VB code. I mean surely a large percentage of code that we all write is done to update the UI so it makes sense that you need to be able to work with the UI directly from the programming language... After all, for pretty much any windows forms app the whole purpose of it is to show someone data and manipulate that data based on what they click and press, so why try and distance the things that they click and press from the programming logic. Dont get me wrong, I know you can do things like change a label's text or whatever from VB code in a WPF project but the whole "separation" thing just seems unnecessary to me.
I guess it might be good for huge enterprise level business apps but for people like myself it doesnt seem to provide any benefits.
Actually separating the UI from the rest of the program is a design of n-tier.
An example...
UI
Business Rules
Data Layer
Database
So separating the UI from the business rules and even other apps like Fat Clients can have big improvements in many areas if separated.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 17th, 2009, 09:42 AM
#53
Re: You owe it to yourself to use WPF
 Originally Posted by DeanMc
Chris, how are you getting on? I cant do a lot of coding until monday unfortunately but I have been playing with silverlight. Are you a convert yet?
I'm struggling to get ListViews to work the way I want them to as the ListViewItem class doesnt seem to have the same properties that it has in winforms .NET 
Basically I want to display some info in a datagridview style and as there is no DGV control for WPF I am trying to use a ListView to do it but all of the examples seem to be using DataBound controls and I dont ever use data binding...
I'll post a new thread in the VB.NET section about this to see if anyone can help
-
Jan 17th, 2009, 11:42 AM
#54
Re: You owe it to yourself to use WPF
 Originally Posted by RobDog888
Actually separating the UI from the rest of the program is a design of n-tier.
But wasn't he whinging about the "code behind" concept here?
We keep hearing about how liberal arts majors will whip up the UI and then troglodyte programmers will add code "behind" that. Farce!
Just to start with you end up dealing with UI elements with default names created by the GUI designer tool (bleh). I also can't see how one can create the "form" of an application with little concept of its "function."
And as stated (maybe overstated) above, much of the time you need to micromanage the UI elements in code to get the required behavior anyway. At least I seem to see lots of code and questions here indicating that default control behaviors just aren't enough for many people.
However I have no quarrel with tier separation. I think a lot of people here only write monolithic single user desktop applets though. They may never have had to deal with the kinds scalability and information security issues tiering addresses.
You might have a hard sell among those folks. It can be a bit like explaining color to a blind person.
-
Jan 17th, 2009, 02:02 PM
#55
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
I have to disagree, while any level of separation will result in more code, it does tend to be more elegant and I need not bother reiterating the pros of uncoupling the UI from the rest of the application as you understand that well enough.
As for your "Farce" statement, blend only requires a knowledge of Xamal not a programming language, even hooking up events is done in Xamal so yes arts majors could very well be making UI's.
The idea of WPF "IS" to enable UI creation without knowledge of function. The artist will simply be told the type of data and they will be in charge of presentation. Most artists present information many times better than programmers.
WPF is not only about artists. It is merely a move away from the new and will most likely evolve from where it is now very fast.
All controls are designed to be stateless so the default behaviour is irrelevant and also the included controls are PURE .net controls (not win32 hooks). I cant see how you find micromanaging themes irksome compared to sticking 3 or 4 controls together and pretending they are a new control.
The fact of the matter is WPF allows proper control creation as opposed to current custom controls which are mostly just elegant hacks built on an aging system.
-
Jan 17th, 2009, 02:04 PM
#56
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Chris, data is much more powerful in WPF than before. They have changed how data is used, retrieved and displayed from a database. I really suggest this book as it is the best source so far.
-
Jan 17th, 2009, 02:15 PM
#57
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Sorry not statless, controls are lookless, they just have a default look.
-
Jan 18th, 2009, 09:47 AM
#58
Re: You owe it to yourself to use WPF
Well dean I have to say so far I am not impressed! lol see here: http://www.vbforums.com/showthread.php?t=554097
All that just to stick some items into a listview and god knows how I am actually going to refer to each of those items from code when I want to actually do something with them lol maybe I should read that book you mentioned first
-
Jan 18th, 2009, 12:55 PM
#59
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Sorry man im in work so only seen this now. First off WPF datagrid and some other pure.net conrols: http://www.codeplex.com/wpf/Release/...eleaseId=15598
Secondly the ebook i have for you will help you out with data access. Also because all controls are lookless you will see that a templated listbox will be just as good (if not better!)
When you see how templates function lookless controls will also make more sense.
Il be home later and pass that ebook on to you!
-
Jan 18th, 2009, 01:21 PM
#60
Re: You owe it to yourself to use WPF
OK cool cheers I'll see if it all makes more sense then
-
Jan 18th, 2009, 05:36 PM
#61
Re: You owe it to yourself to use WPF
grrrr just spent 35 mins trying to get a simple timer to work! Why the hell have they removed the ability to add components from the toolbox It makes using things like timers and backgroundworkers an awful lot more work...
-
Jan 18th, 2009, 05:40 PM
#62
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Timers are not in the control box for WPF, what do you need a timer for?
-
Jan 18th, 2009, 11:05 PM
#63
Re: You owe it to yourself to use WPF
I hate adding times via the designer. It's just not natural... in my opinion, anyway.
-
Jan 19th, 2009, 04:41 AM
#64
Re: You owe it to yourself to use WPF
 Originally Posted by Kasracer
I hate adding times via the designer. It's just not natural... in my opinion, anyway.
What about BackGroundWorkers then? Do you add them just through code and hook up all the events yourself? Because thats what you have to do in WPF...
-
Jan 19th, 2009, 06:52 AM
#65
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Im with Kas on this one chris, I tend to hook most things up in code
-
Jan 19th, 2009, 08:25 AM
#66
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
So, this is a test of course but it is basicly the style I will be using for a notes application:
-
Jan 19th, 2009, 10:13 AM
#67
Re: You owe it to yourself to use WPF
Ah-ha! I finally found it.... sorry it took me so long.... but here's how to get a listbox to have multi lined items and rounded corners.
First the XAML:
Code:
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen">
<Grid>
<ListBox x:Name="lstItems" Width="200" MaxHeight="300" FontSize="16" Background="Blue" >
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Black" Background="White" Margin="4,4,4,4" BorderThickness="1" CornerRadius="5" Width="150">
<StackPanel Orientation="Vertical" Margin="3,0,3,0">
<StackPanel Orientation="Horizontal" Background="AntiqueWhite">
<TextBlock FontSize="16" Text="{Binding Path=FirstName}" />
<TextBlock FontSize="16" Text=" " />
<TextBlock FontSize="16" Text="{Binding Path=LastName}" />
</StackPanel>
<TextBlock FontSize="12" Text="{Binding Path=Age}" />
<TextBlock FontSize="12" Text="{Binding Path=FavoriteMovie}" />
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
The "data" class:
Code:
Public Class MyPeopleData
Private _lastName As String
Private _firstName As String
Private _age As String
Private _favoriteMovie As String
Public Sub New(ByVal firstName As String, ByVal lastName As String, ByVal age As Int32, ByVal favoriteMovie As String)
Me.FirstName = firstName
Me.LastName = lastName
Me.Age = age
Me.FavoriteMovie = favoriteMovie
End Sub
Public Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal value As String)
_lastName = value
End Set
End Property
Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal value As String)
_firstName = value
End Set
End Property
Public Property Age() As String
Get
Return _age
End Get
Set(ByVal value As String)
_age = value
End Set
End Property
Public Property FavoriteMovie() As String
Get
Return _favoriteMovie
End Get
Set(ByVal value As String)
_favoriteMovie = value
End Set
End Property
End Class
And then the code to load into the list box:
Code:
Class Window1
Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
lstItems.Items.Add(New MyPeopleData("Han", "Solo", 45, "Star Wars"))
lstItems.Items.Add(New MyPeopleData("James", "Kirk", 36, "Star Trek"))
lstItems.Items.Add(New MyPeopleData("Martha", "Jones", 24, "Dr. Who"))
lstItems.Items.Add(New MyPeopleData("Will", "Smith", 32, "Independence Day"))
lstItems.Items.Add(New MyPeopleData("Christian", "Bale", 40, "The Dark Knight"))
lstItems.Items.Add(New MyPeopleData("Hugh", "Jackman", 46, "Wolverine"))
End Sub
End Class
In XAML it's the CornerRadius attribute that controls the rounded corners... as an FYI - I had to play wit the CornerRadius and the Margin attributes to get it to look somewhat right... the original code I had copied didn't allow enough room between the edge and the data, so the left side was rounded, but the right got squared off... increasing to the top margin dropped the data down just enough to get the rounds on both sides.
-tg
-
Jan 19th, 2009, 10:21 AM
#68
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
-
Jan 19th, 2009, 10:26 AM
#69
Re: You owe it to yourself to use WPF
The more I play with it, the more I'm liking it.... I think my next project will be done in WPF.... don't know what it will be just yet, but I've got a couple of things I've been tossing about in my head... Might be a good opportunity to have a good go at WPF.
-tg
-
Jan 19th, 2009, 10:31 AM
#70
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Im starting a simple information manager application, Its going to look like a standard windows application then im going to post videos on how to pretty it up!
-
Jan 19th, 2009, 01:41 PM
#71
Re: You owe it to yourself to use WPF
I've still got my animation trigger problem I posted on the official MSDN WPF forum and so far no one on there seems to have any idea either...Seems odd as I thought it would be a very common thing to want to do :S
-
Jan 19th, 2009, 02:03 PM
#72
Re: You owe it to yourself to use WPF
Well I finally got it working, so here's the solution for anyone else having the same problem (as there doesnt seem to be much on google about it, apart from for Silverlight but that requires a different solution)
That reminds me, isnt it time we had a WPF forum section on here This isnt really the place to post a solution to a WPF problem but I dont know where else to put it lol
Problem
You have created a StoryBoard animation either in Blend or just by typing it out in the XAML code view. You want to start this StoryBoard manually from your code-behind file (check me out with my correct terminology).
Solution
As the StoryBoard is actually declared in the Window.Resources part of the XAML code (or at least it is when you use Blend to create it) you can use the TryFindResources function to return your StoryBoard object by passing it the Key attribute of the StoryBoard. So say you named your StoryBoard "TestSB" in Blend, this is how you could start it in your WPF code-behind:
vb.net Code:
Dim MyStoryBoard As StoryBoard = TryFindResource("TestSB")
MyStoryBoard.Begin()
Obviously error checking etc would be needed but thats the basic idea. Hope it saves someone some time!
Last edited by chris128; Jan 19th, 2009 at 02:07 PM.
-
Jan 19th, 2009, 02:19 PM
#73
Re: You owe it to yourself to use WPF
That reminds me, isnt it time we had a WPF forum section on here This isnt really the place to post a solution to a WPF problem but I dont know where else to put it lol
I agree, especially since WPF is language agnostic... it would be nice to have a WPF section....
I'll put in a request in the Forum feedback...
-tg
-
Jan 19th, 2009, 02:33 PM
#74
Re: You owe it to yourself to use WPF
I already did a few months ago and wasnt told it wasnt popular enough I think, but maybe now it is? Now that 3 of us are trying to use it :P haha
-
Jan 19th, 2009, 02:36 PM
#75
Re: You owe it to yourself to use WPF
Another handy thing that just took me ages to find out is that you can hook up an event to handle the Completed event of a StoryBoard so that you know when an animation has finished. Very useful if you are using an animation to exit a form (fade out etc). I'm not used to all this manual event hooking up stuff and have to say it does feel like we have kind of taken a step backwards instead of forwards as a lot of people (like myself) relied quite heavily on the designer to generate event handlers etc for us. I guess its teaching me things that will come in handy in general .NET antics but thats not the point really lol
-
Jan 19th, 2009, 03:05 PM
#76
Thread Starter
Frenzied Member
Re: You owe it to yourself to use WPF
Well if you post it I will second it techgnome. Chris you should always hook up your event handlers in code if you ask me that means you get a feel for its parameters when writing custom handlers.
-
Jan 21st, 2009, 05:21 AM
#77
Re: You owe it to yourself to use WPF
-
Jun 29th, 2009, 11:14 AM
#78
Re: You owe it to yourself to use WPF
Just wanted to post a little feedback on this 5 months down the line... basically to sum up: I now use WPF for all of my projects and would not go back to winforms unless I absolutely had to As you have all seen with this thread, there are a lot of things to get used to when you first move from winforms to WPF but once you get over the initial stumbling blocks and get your head around things then life is sweet. Well... not sweet, I still have the odd WPF related problem but most of the time I can just do whatever I want without a problem and I have so much more flexibility than I would have in winforms in terms of the UI.
As Dean pointed out earlier in this thread though, WPF is not just all about the UI, it has improvements in many other areas and I think everyone should at least give it a chance, especially when .NET 4 comes out and they fix the damn blurry text issue (which is probably the worst thing about WPF in my opinion)
-
Jun 29th, 2009, 01:38 PM
#79
Re: You owe it to yourself to use WPF
I wish I had your confidence chris. I've tried WPF about 4 times now and I also keep stumbling on the dumbest things. My problem, is that the UI of all my applications are highly intelligent. They won't let you put in bad information, or have any button lit up when all the conditions of it's usage aren't met. I've tried hard to reproduce some of this behavior with WPF but keep falling on my face.
Also, as I think you even mentioned earlier, I hate the "XML" style of programming. My eyes go cross looking at all those Greater-Than/Less-Than marks. It made sense for HTML a many moons ago when a web page was 80% text and 20% code tags, but these days, pages are 95% code tags and 5% actual text, with things like XML and XAML being more in the 98%-2% range... It's like me putting all my program lines in VB.NET in double-quotes, and only actual strings would have no quotes around them. 
Syntax-wise, I'm of strong opinion the majority of programming language's program code should be plain-text and only special conditions such as specific data-types warrant whole-line modifiers such as [brackets], <tags>, or "quotes".
Finally, I'm also totally for the idea that the end-user should have skin-control over all his programs, regardless of the program; and that means adherence to themes. When I launch 10 different applications, I DON'T want 10 different styles of buttons! I want them all to have the button style I chose for them to have in accordance with the theme I picked for the OS. I handle more problem calls these days because of inconsistent interfaces on programs than I ever have in the past. I'm sure there will be custom user-controls and custom behaviors of standard controls to fit circumstances, and that's fine, as long as they adhere to theme standards.
WPF sounds like a great system, but I'm still of the opinion it needs to be wrangled under control before any kind of widespread adoption. Maybe after my current project, I'll try WPF once again and find yet another set of tutorials for Design/Blend. I'll look for this mysterious superior functionality that's not only supposed to be as quick and easy to use as Winforms, but totally customizable and more feature laden as well.
Anyways, just my 2 cents on the matter.
-
Jun 29th, 2009, 03:40 PM
#80
Re: You owe it to yourself to use WPF
Yeah thats fair enough and as you know I was exactly the same, I despised WPF for quite a while and gave it several 'goes' but they all ended with me being very frustrated. I also totally hated XAML but to be honest now I love it, I very rarely drag and drop anything from the toolbox... seriously if I want a new button I just type <Button Content="Click Me" Margin="2" /> and I'm pretty much done. One reason for this is because dragging and dropping controls from the toolbox with WPF just results in disaster because VS positions everything by setting the Margin property to ridiculous amounts and then when you add another control or move your control into another container etc it all goes to sh*t... so I guess that might be why I type XAML instead but I actually prefer it anyway now.
A recent example where I found WPF much easier than winforms is when making a custom error message box. Here's an example of the end result:

To make that in winforms, whilst it certainly wouldnt be impossible, I believe it would involve a lot of measuring of strings etc to make sure each area (and the form) was big enough to fit all of the text in all of the time etc but with WPF I just simply set the TextBlock's TextWrap property to Wrap and create a couple of grids and stack panels and it all automatically lays itself out the way its supposed to every time with no code at all. Also when I created a custom messagebox window, to get the OK button to always be in the middle of the window no matter how wide the window is I simply set the HorizontalAlignment property to Centered like so: <Button Name="OkBtn" Content="OK" HorizontalAlignment="Centered" /> and thats it.
Also, just in case you didnt know, VS 2010 was made with WPF so you cant say its not really useable yet :P (although I admit it does still have its problems)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|