in

vbCity Blogs

New (temp) place for vbCity Blogs

CanOz Blog

Neil Knobbe's place for Visual Basic.NET and WPF

April 2009 - Posts

  • TabControl with WPF and Visual Basic.NET 2008 Project

    TabControl with WPF and Visual Basic.NET 2008 Project

    Sometimes it just takes me a while, but I finally got to the point where I figured I should also be including the Visual Basic projects to go along with the posts and the videos.

    You can download the project that goes along with the TabControl with WPF and Visual Basic.NET 2008 post.

    The project can be downloaded from here.

    My apologies for the size of the file.  It is a little bloated because of having the video file.

  • TabControl with WPF and Visual Basic.NET 2008

    TabControl with WPF and Visual Basic.NET 2008

    A while back I posted up about showing more interesting content on that tab
    of a tab control using Windows Presentation Foundation (WPF).

    In the example that I posted, I created the custom look of the tab control just using
    XAML and I thought that it would be good to also show how to do the same thing
    using Visual Basic.

    To do this I decided to cut back to the basics for the content of the tabs and I started
    with a tab control with four tabs.  The first tab had a textblock with some text as well
    as a couple style blocks in it.  The second tab starts with a stack panel.  The third
    and fourth tabs have grids on them.

    The XAML for my base project is.

        1 <Window x:Class="Window1"

        2  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        3  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        4  x:Name="Window1"    Title="Window1" Height="437"
           Width
    ="532" WindowStartupLocation="CenterScreen">

        5  <Grid x:Name="Form1">

        6     <TabControl>

        7         <TabItem x:Name="Tab1">

        8             <TabItem.Header>

        9                 <TextBlock x:Name="Tab1TextBlock">

       10                     <Span x:Name="Tab1TbSpan1">Words</Span>

       11                     <Span x:Name="Tab1TbSpan2">in</Span>

       12                     <Span x:Name="Tab1TbSpan3">Italics</Span>

       13                 </TextBlock>

       14             </TabItem.Header>

       15         </TabItem>

       16         <TabItem x:Name="Tab2">

       17             <TabItem.Header>

       18                 <StackPanel x:Name="Stack" Orientation="Horizontal">

       19 

       20                 </StackPanel>

       21             </TabItem.Header>

       22         </TabItem>

       23         <TabItem x:Name="Tab3">

       24             <TabItem.Header>

       25                 <Grid x:Name="Grid1">

       26 

       27                 </Grid>

       28             </TabItem.Header>

       29         </TabItem>

       30         <TabItem>

       31             <TabItem.Header>

       32                 <Grid x:Name="Grid2">

       33 

       34                 </Grid>

       35             </TabItem.Header>

       36         </TabItem>

       37     </TabControl>

       38  </Grid>

       39 </Window>

     

    The window does not look too interesting yet,

    but we will make it look better soon.

    Tab 1

    Within the XAML of the text block that is in the first tab, I have added in where
    I want the different styles to be.  I have giving the each span block a name so
    that it can be referenced by the code behind.

    There are different ways to go about this depending on what you want to do. 
    As you will see I have created one style with several different properties, since
    I am only going to be setting one property per span block I have only created
    one new style, or you can create a new style for each span block if you are
    going to have different styles for overlapping properties.

    I started off by declaring a variable as a New Span, then I set the properties
    for the variable that I wanted.

        1 Dim s As New Span

        2 

        3 s.Foreground = Brushes.Blue

        4 s.FontWeight = FontWeights.Bold

        5 s.FontStyle = FontStyles.Italic

    Now that I have the properties set, I just need to assign them to the various
    spans that I have on my tab.

        8 Tab1TbSpan1.Foreground = s.Foreground

        9 Tab1TbSpan2.FontWeight = s.FontWeight

       10 Tab1TbSpan3.FontStyle = s.FontStyle

     

    Tab one now has something more elaborate on it.

    Admittedly, I could have just used Brushes.Blue to set the Foreground of
    the first span, but by creating and using a new span I can now re-use this
    over and over in my code if I wanted to and if I wanted to change the
    colour, then I would only have to change one line of code rather than
    possibly having to several to change.

    Tab 2

    Tab 2 starts out with a stack panel on it with the orientation of the stack
    panel set to horizontal.I could have set the orientation of the stack panel
    with VB code if I wanted by using:

       12 With Stack

       13     .Orientation = Orientation.Horizontal

       14 End With

     

    if I wanted.

    In the stack panel I am going to place a text block, a rectangle and a circle.

    To add the text block, I need to start out with declaring a new text block
    then set the Text property.  With that done the last line of code adds the
    text block to the stack panel.

       16 With tb As New TextBlock

       17 

       18 tb.Text = "Circles and Rectangles"

       19 

       20 Stack.Children.Add(tb)

     

    I now have a caption on the second tab.

    Next I want to have a circle showing on the tab, so I declare a variable to
    hold a new ellipse and then set the Height, Width, and Fill.  I also set the
    Margin for the ellipse to a new thickness and pass the numeric
    representations of left, top, right and bottom to position the ellipse on
    the tab.  Once I have the properties I want set, I add the ellipse to the
    stack panel.

       23 Dim c As New Ellipse

       24 

       25 c.Height = 20

       26 c.Width = 20

       27 c.Fill = Brushes.Blue

       28 c.Margin = New Thickness(10, 0, 0, 0)

       29 

       30 Stack.Children.Add(c)

     

    Tab 2 now has a caption and a circle on it.

    The last item I wanted on the tab was a rectangle, so I did much the same
    for this as for adding the ellipse.  I declared a variable to hold a new
    rectangle then set the Height, Width and Fill.  Again I set the margin
    property to a new thickness to position the rectangle on the tab.  Then I
    added the rectangle to the stack panel.

       32 Dim r As New Rectangle

       33 

       34 r.Height = 15

       35 r.Width = 25

       36 r.Fill = Brushes.Red

       37 r.Margin = New Thickness(10, 0, 0, 0)

       38 

       39 Stack.Children.Add(r)

     

    I now have my desired look for the second tab.

    Tab 3

    Tab 3 will hold an image.

    Once again I start off by declaring a variable which will hold a new image,
    then set the Width and Source properties.The source property is declared
    as a New BitmapImage and the path of the image file, as well as what
    kind of Uri the path is, are passed as parameters of the Uri of the file. 
    The image control is then added to the grid on the tab.

       41 Dim v As New Image

       42 

       43 v.Width = 80

       44 v.Source = New BitmapImage(New Uri("Lizard004_RJ.JPG", _
                                     UriKind.Relative))

       45 

       46 Grid1.Children.Add(v)

     

    The third tab now displays an image.

    Tab 4

    The last tab on my tab control is going to display a video.

    I start out by declaring a variable to hold a new instance of a media element,
    then set the Width and Source properties of the element before adding the
    control to the grid on the fourth tab.

       48 Dim m As New MediaElement

       49 

       50 m.Width = 80

       51 m.Source = New Uri("butterfly.wmv", UriKind.Relative)

       52 

       53 Grid2.Children.Add(m)

     

    The tab now displays the video and completes the effect I was after.

    So you can see that it can be just as easy to do in Visual Basic what you
    can with XAML.

  • Video for Gadget Window

    Video for Gadget Window

    I have finished the video showing the process for creating a Gadget Style window.

    You can download it from here.

     

  • Multi-Line commenting

    Multi-Line commenting

    There are times when I have to wonder if I am the only person who does not know
    some things.

    I ran into this self doubt again the other day when I was watching one of Ron Cundiff's
    VB.NET Soup To Nuts WebCasts.

    During the WebCast one of the participants asked if there was a way to comment multiple
    lines of code.  When I heard this my ears perked up and I got very interested.

    In the, almost, ten years that I have been writing code, I always have commented out any
    lines of code I didn't want to run one line at a time.  What a time consuming effort that can
    be depending on the number of lines you are working with.  I also ended up with unformatted
    (not indented) code,

    and usually put the comment apostrophe in the wrong place when an indented line of code
    moved once the one above had been commented out.

    Well this is all changed now.  Low and behold there are buttons in the Visual Studio IDE that
    let you comment out, or uncomment, any lines of code that you have selected.  All this time
    I had a simple way literally staring me in the face.

    Right in the main Toolbar there is the Comment Button

    and the Uncomment Button.

    Now all I need to do to comment, or uncomment, multiple lines is highlight the code I
    want and click a button.

    One other great thing about this feature is that the code stays formatted (indented) even
    after commenting which, I believe, makes it much easier to read.

    *sigh*  Now I only have to wonder what other time saving “wonders” I will have to wait
    ten years to discover.

  • ClickOnce Deployment – Deploying files with your application

    ClickOnce Deployment – Deploying files with your application

    In a previous post, I showed you how you can deploy your application using ClickOnce. 
    Looking at how to deploy extra files, like my first look at ClickOnce, was prompted by a
    post on vbCity.

    Now I will admit that I wasn’t as sharp answering the original question as I could have
    been so be gentle with your opinion of me if you read through the thread.  (In fact it
    took me two days to work out that when the person asking mentioned the "Publish" tab
    that they meant ClickOnce.  I guess this is what I get for trying to answer questions a 3:30am.)

    Once I was in synch with the problem a little research provided me with an answer.

    You would have thought that once you added the files to your project in Visual Studio
    that they would be automatically included in the deployment package but this is not the
    case.  I added the file to my project,

    but if you were to then take a look at the files that are included in the deployment
    package by going to the Publish tab of your projects properties page and click the
    "Application Files" button you get a nasty little shock.

    No additional file even though we have added it to the project.

    The reason for this is that we have not told Visual Studio what we want to do with
    the file.  What is needed is to make one change to the properties of the file.  The
    property we want to change is the Build property.

    By default, depending on the extension of the file, when you add a file to a Visual
    Studio project the Build property is set to "None".

    (If you were using a deployment method like creating a Windows Installer file (.msi)
    then this would not be a problem because of the was you create the Installer file. 
    With ClickOnce deployment unless you change the Build property it assumes that
    you don’t want to include the file in the deployment package.)

    In the properties window of the file select “Content” from the choices for the files
    Build property.

    Now ClickOnce will recognize that the file is to be deployed with your application and
    if you go back to the My Properties page of your app, click on the "Publish" tab and
    click on the "Application Files" button you will see that the file in the list of files to be
    included.

    Publish your application, then you can do a test install and you will see by looking at
    the files that are installed on your computer now include the additional files.

  • ClickOnce increments

    ClickOnce increments

    Rockford Lhotka posted up some details about how ClickOnce handles what is downloaded
    when it performs an incremental update. 

    The more I look at ClickOnce the more I am coming to appreciate it.

    I know this goes against the ClickOnce idea, but if the end user could only determine
    where the Application is installed.  I suppose if I want to be that fussy I would just distribute
    and install via a Windows Installer file.

  • Deploying applications with ClickOnce

    Deploying applications with ClickOnce

    ClickOnce Deployment

    A recent post on vbCity regarding deploying an application with ClickOnce got me
    wondering about doing deployment with ClickOnce.

    I have always done deployment of applications by creating and using a Setup and
    Deployment package which created a .msi installer file, so it was interesting to
    see some of the differences between the two distribution methods.

    First off I created a simple application to test the ClickOnce distribution and
    installation method with.  What I created was nothing special, just a windows form
    with at button that, when it is clicked, a message box is shown.

     

    As you can see the application is nothing special.  One other thing that I did was
    add a version number to the text of the form.  I did this to show how ClickOnce
    deployment installs newer versions as they are available.  I will get to this a little
    later.

    Once your application is ready to go you want to open up the My Project page
    from the solution explorer.

    On the My Project  page click the Publish tab.

    From this page, you define where your application is going to be available from
    and how it is going to be installed on the client machine.

    Taking a look at the publish page from the top down the first thing you will want
    to enter will be the location (URL) that you are going to publish to.

    As you can see from the image above, you have three options for the location
    that you are going to publish to.  You can publish to a web site
    (http://www.somesite.com) but to do this you must have FrontPage extensions
    enabled on the web site.  You can publish to a ftp server (ftp://www.somesite.com)
    as long as you have ftp permissions for the site, or you can publish to a local file
    (C:\myApplication). (For distribution this last option is not really that realistic
    unless you are on an internal network where you can share out the directory to
    others on the network.)

    The next option you have is to determine if you application is available offline or not.

    If you don’t want the users to be able to access your application offline then
    select the online option.  This will cause your application to run, but not show in
    the start menu of the user’s computer.  They would need to download the
    application each time they wanted to use your application. 

    If you make the application available offline then a shortcut is included in the
    start menu of the computer making the application accessible all the time.

    To the right of the Install settings there is a group of four buttons.

    These buttons define what files are to be included with your application, any
    prerequisites that the end user must have installed on their computer to run
    your application, how and when to get updates as well as options such as
    adding the publishers name, product name etc.

    Under the install mode and the buttons there is the version boxes plus the
    option to automatically increment the revision with each publish.

    Keeping the increment box checked is, I believe, quite important.  If you don’t
    remember to increment the version number when you republish the
    application then the next time the application checks for updates it looks at
    the version number and if that number has not changed, even though your
    application may have, it assumes that there is nothing newer and opens the
    currently installed version.

    The last two items on the window are the Publish Wizard and Publish Now
    buttons.

    The Publish Wizard button will open a series of dialogues and walk you
    through the settings that you want your installer to use.

    The Publish Now button will use the information that you have entered
    on the page and create the installer files then, if you are deploying the
    files to either a web site or ftp site, prompt you for log on details.

    Simply insert your username and password then click the OK button and the
    files required will be uploaded to the URL you specified.

    You can see in the image above that ClickOnce has created two files and one
    directory on the web server.  Within the Application Files directory you would
    find one directory containing each version that has been published and uploaded.

    I just happen to have two versions in the application files directory and the one
    that will get distributed will always be the latest version. (I mentioned earlier that
    I had put a version number on the text of the form and the version number you
    should see is 2 not 1 like the image of the form above.) It would not matter how
    many older versions I have on my server.

    Now you may distribute the address of your application to your clients.  The file
    that you want to point to is the Application Manifest file, not the setup file. 
    From the image above I would point people to the URL
    http://www.neilknobbe.com/clickonce/ClickOnce.application.  (The link is live
    and you can navigate to it, download and install the application that I
    mentioned at the start of this post.  It is not very exciting, but it shows how
    ClickOnce works.)

    The prerequisites for installation, which you would have set earlier, are checked.

    If all is ok, the user will be prompted to install the application.

    Once installed your ClickOnce deployed application is ready to use.

     

  • Text and Image for Button with Visual Studio 2005

    Text and Image for Button with Visual Studio 2005

    Ok, let’s call this page 22,492 in the book of things I did not know about
    Visual Studio 2005.

    I was reading something the other day, if I can remember or find it I will post up a link,
    and was surprised that I had missed this little bit before. 

    (I have recently been reading “WPF for those who know Windows Forms” that can be
    found here  and watching webcasts by William Steele on his WPF Soup To Nuts series
    so it could have could have come from one of those.)

    What was mentioned was having both text and an image on a button.  I knew it was
    possible, but I didn’t know just how easy it was to do.

    By default when you add an image to the button the text of the button is overlays the image.

    There is a property of a button which helps us set the relation of the text to the
    image.  This name of this property is TextImageRelation.


    The TextImageRelation property has five options:

     

    • Overlay
    • Image over text
    • Text over image
    • Image before text
    • Text before image

     

    The options are pretty much self explanatory.  Below are screen shots showing
    the different positions.

    Image over text:

    Text over image:

    Image before text:

    and lastly

    Text before image:

     

  • Video for WPF expander

    Video for WPF expander

    The companion video to my post on the expander control in WPF is now available for download.

    The video can be found here.

  • Video for tab control with WPF

    Video for tab control with WPF

    A couple of days later than I had planned, but I finished the video that is the companion of this post about custom content in the tabs of a tab control in WPF.

    You can download the video here.

     

    Posted Apr 12 2009, 06:02 PM by CanOz with no comments
    Filed under: ,
  • TabControl background colour video

    TabControl background colour video

    This is a follow up on the post about changing the colour of the TabPanel part of the tab control. 

    I created a video showing how I went about changing the template of the tab control using Expression Blend.

    You can download the video to watch from here.

  • Creating a Gadget style window with WPF and Visual Basic.NET 2008

    Creating a Gadget style window with WPF and Visual Basic.NET 2008

    I don’t know if it is a case of my actually knowing more or the fact that doing stuff with
    Windows Presentation Foundation (WPF) is easier.  To me it seems doing what I want
    is getting quicker these days.

    The ability to create and use semi-transparent forms has been around for a while now,
    but the process to creating these types of forms has not been the easiest.

    Visual Basic.NET 2005 gave us access to the opacity property of a Windows form. 
    The down side of this was that it made the whole form, including any controls on the
    form, opaque thus still showing some of the form itself.

    With very little code, creating a gadget type window with WPF is relatively easy. 
    In fact look of the Window can be created with as few as 5 lines of code.  How and
    what your gadget window does is entirely up to you.  (I will apologize at this point in
    time for how bad my gadget will look.  I am not a graphical person at all and my
    colour coordination is really, really bad.)

    What I decided to do was I wanted something that would play some music as I
    worked on my computer.  VbCity Leader and Microsoft MVP Ged Mead showed
    us how to add sound to a WPF app, so I decided to incorporate that idea to my project.

    Now admittedly what we will end up at the end of this post is not very exciting or
    versatile, but it is a start and can be expanded on to suit your wishes.  I just
    want to show the basics on how to create the gadget window.

    The first thing we need to do is create a new WPF Application and the XAML for
    it is pretty basic.

    Before you can start adding code to the code behind page there is one thing that
    you must do and that is you must add a Name property to the XAML of the Window. 
    Until you do that you don’t have, on the code behind page, access to the Events
    of the window.

    I know that it looks like can get to the Window1 Events, but if you tried to set or change
    any settings for Window1 you would get errors.

    So in the XAML of your page you just need to add a Name property.

    I also changed the Title of the page as you can see the title in the Taskbar of your
    computer.

    Now that we have a name for the form we can tap into the events of the page itself
    and start adding code to the code behind.  This was when I ran into the first gotcha.

    The first gotcha I ran across was in the placement of the code I was using.  The first
    time I tried to add the code I used the Form_Loaded event, an event that I have used
    for setting properties of the form in the past, which has always worked like a charm.  
    The code I used was:

    What happened, however, when I tried to run my project to see what happened was
    I got an InvalidOperationException .  The reason this exception was thrown is because
    you can not set the AllowsTransparency property of a form once the window has
    been shown.

    To get around this problem I put the code in the Initialize event of the form which let
    me set all the properties of the form that I wanted.

    As you can see by the code above, I have set the height and width of the form to 200,
    then I made changes to the three properties that really make this a gadget type window.

    The first property I set was to set the AllowsTransparency to True.  What this
    property does is indicates whether the client area of the window supports transparency.

    The second property set was the Background of the form.  This is set to the color Transparent.

    The third property set was the WindowStyle.  What the WindowsStyle property does
    is tell the application what sort of border to put on the window.  By setting the style
    to None, the ControlBox which you would normally see at the top right of a window are
    not show effectively removing the border of the form.

    If you were to run the project now you would not actually see anything because your
    form is transparent and there are no other controls on it just yet.  You could verify
    that it is running by taking a look at the Taskbar on your computer.

    (You certainly don't need to set the properties of the form, then add controls like I
    am doing, you could set up your form like you want it then make whatever changes
    you want to make.)

    On my form I decided that I am going to have an Ellipse and two Buttons.  One button
    is to start the music and one to exit the Application.

    Let's start with the Ellipse since this will be what our "form" will end up looking like.

    First off I added the Ellipse to the XAML of my form making sure that I gave it a name
    so that we could set its properties on the code behind page.

    Next I made the changes to the properties of the Ellipse on the code behind page.  I
    set the Fill property (again I apologize for any lack of graphic artistry), the Opacity,
    Width, Height and because I didn't want to just have a flat Ellipse showing I added a
    BitmapEffect.

    The Opacity and BitmapEffect properties are the interesting ones here.  By setting
    the Opacity I can regulate how see through my ellipse is and the BitmapEffect has
    added a beveled edge around the ellipse, just to add a little bit of depth to the graphic.

    Now when the project is run you can see the ellipse on the form.

    Next buttons are added to the XAML of thewindow again making sure that Names
    are given to each one.

    Then set the properties of the buttons on the code behind page.

    The Height, Width and Content are set for both buttons as well as the VerticalAlignment
    property.  For the button that will exit the application the Forground property is set to
    Red to have it stand out.

    The last property that is assigned for the buttons is the Margin property which is used
    to position the buttons where I wanted them on the form over the ellipse.  Setting this
    property was a little hit and miss as I was setting it via code so I could not see on the
    form where the buttons were actually going to end up.

    Now that I had the form looking like I wanted, all that was left was to be able to move
    and position the window anywhere I wanted to put it, have music play when I clicked
    the > button and to be able to quit the application.

    To make the window move to a different position on the screen all that is required is
    one small line of code in the MouseLeftButtonDown event of the window.

    Now if the application is run and the left mouse button is held down you can move
    the ellipse anywhere on your screen.

    To close the application, just put the following code in the Click event of the close button.

    The last thing to be done is to make music.  (Thanks once again to Ged for pointing
    out the pitfalls of playing music.)

    (Admittedly there could be a whole lot more functionality to the application here to let,
    for example, the user either enter or select a path and have the application play each
    audio file in the directory one after the other, but that is more than I wanted to show
    here.  Maybe I will get to that in a future post.)

    We start with adding the Imports Statement

        1 Imports System.Media

    Add a Variable to hold our instance of a media player

        1 Dim MyPlayer As MediaPlayer

     

    Lastly the code to play the music

    So the complete XAML for the gadget is:

        1 <Window Name="Win1" x:Class="Window1"

        2    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        3    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        4    Title="Neil's Gadget">

        5     <Grid>

        6         <Ellipse Name="Ellipse1" />

        7         <Button Name="Button1">Button</Button>

        8         <Button Name="Button2">Button</Button>

        9     </Grid>

       10 </Window>

    and the complete code:

        1 Imports System.Media

        2 Class Window1

        3     Dim MyPlayer As MediaPlayer

        4     Private Sub Win1_Initialized(ByVal sender As Object, ByVal e As System.EventArgs) Handles Win1.Initialized

        5         With Win1.Height = 200

        6             .Width = 200

        7             .Background = Brushes.Transparent

        8             .AllowsTransparency = True

        9             .WindowStyle = Windows.WindowStyle.None

       10         End With

       11         With Ellipse1.Fill = Brushes.Tomato

       12             .Opacity = 0.5

       13             .Width = 150

       14             .Height = 110

       15             .BitmapEffect = New System.Windows.Media.Effects.BevelBitmapEffect

       16         End With

       17         With Button1.Height = 20

       18             .Width = 20

       19             .Content = "X"

       20             .Foreground = Brushes.Red

       21             .VerticalAlignment = Windows.VerticalAlignment.Center

       22             .Margin = New Thickness(40, 70, 20, 20)

       23         End With

       24         With Button2.Height = 20

       25             .Width = 20

       26             .Content = ">"

       27             .VerticalContentAlignment = Windows.VerticalAlignment.Center

       28             .Margin = New Thickness(0, 70, 20, 20)

       29         End With

       30     End Sub

       31 

       32 

       33     Private Sub Win1_MouseLeftButtonDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Win1.MouseLeftButtonDown

       34         Me.DragMove()

       35     End Sub

       36     Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click

       37         Me.Close()

       38     End Sub

       39     Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button2.Click

       40         MyPlayer = New MediaPlayer

       41         MyPlayer.Open(New Uri("symphony5_beethoven_radio3.mp3", UriKind.Relative))

       42         MyPlayer.Play()

       43     End Sub

     

    How simple can it get?

  • ClickOnce deployment videos

    ClickOnce deployment videos

    I have finished making videos showing how to deploy and update Applications using ClickOnce. 
    All the videos have been zipped so that you can download them and watch at your leisure.

    I orignally thought it was going to be in two parts, but decided in the long run to make it three
    parts to keep the length ove the video and size of the files down.

    Part 1 goes through the settings.

    Part 2 shows the publishing process as well as downloading and installing.

    Part 3 shows how ClickOnce handles updates to the Application.

  • WPF Expander control revisited

    WPF Expander control revisited

    I was taking another look at the WPF expander control that I talked about here and discovered
    that you don't actually need to use any code to get rid of the background colour of the control
    when collapsed.

    What I discovered is that if you set the VerticalAlignment of the expander control.  You can
    set this property to Bottom, Center, Stretch and Top.  All but Stretch will hide the background
    colour of the control when the control is collapsed.

    Here is the revised XAML markup for the control:

     

    Posted Apr 12 2009, 02:04 AM by CanOz with no comments
    Filed under: ,
  • Drag and drop code to and from toolbox (part II)

    Drag and drop code to and from toolbox (part II)

    After posting up about this feature   of Visual Studio I got to messing around with it a bit. (Sara Ford's post got me excited about this topic)

    I got to thinking that although it was a great idea to be about to store code snippets in the toolbox, I did get to thinking that it could get confusing having all sorts of code for different things in one tab and be able to separate the code in organized groups would be handy.  Well guess what.  It can be done.

    If you right click on the General tab of the toolbox you can select to add a tab.

    A new tab is created and all you need to do is type in the name that you want your tab to have.

    Now you can organize your code, and control, snippets so they are easy to find.

     

More Posts Next page »
Copyright 1998-2009 vbCity.com LLC
Powered by Community Server (Non-Commercial Edition), by Telligent Systems