Wpf ??
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Wpf ??

  1. #1
    Join Date
    Feb 2001
    Posts
    2,455

    Wpf ??

    I want to use WPF to create my next application, but there doesn't really seem to be support for SDI type interface.

    What I want, is a stack panel along the top displaying buttons that are my menu items, stack panel along the left displaying buttons that are my menu options, and the rest of the area for "content".

    As the user selects a menu / menu item, I want the content area to display a different view.

    Can anyone point me to an article or examply that may help me achieve this??

    Mike B

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,359

    Re: Wpf ??

    What I've done in this situation is to use a tabcontrol with hidden tabs. As a user makes a 'view' selection, the SelectedIndex of the TabControl is changed and a different view is displayed.

    For example, the following code has the ability to display 3 different views:

    First let's declare the 'hidden' tab control style:
    Code:
    <Window.Resources>
    	<Style x:Key="HiddenTabItemStyle" TargetType="{x:Type TabItem}">
    		<Setter Property="Visibility" Value="Hidden"/>
    		<Setter Property="Margin" Value="0"/>
    	</Style>
    	<Style x:Key="HiddenTabStyle" TargetType="{x:Type TabControl}">
    		<Setter Property="Background" Value="Transparent"/>
    		<Setter Property="Margin" Value="0,-15,0,0"/>
    	</Style>
    </Window.Resources>
    Next use the tabstyles in a tabcontrol that contains 3 different views
    Code:
    <TabControl x:Name="_viewContainer"
    	SelectedIndex="{Binding Path=ViewModeId}"
    	Background="Transparent"
    	Style="{StaticResource HiddenTabStyle}" 	BorderBrush="Transparent" >
    	<TabItem Background="Transparent" Style="{StaticResource HiddenTabItemStyle}">
    		<acc:AutomaticView x:Name="_automaticView" />
    	</TabItem>
    	<TabItem Background="Transparent" Style="{StaticResource HiddenTabItemStyle}">
    		<acc:EditView x:Name="_editView" />
    	</TabItem>
    	<TabItem Background="Transparent" Style="{StaticResource HiddenTabItemStyle}">
    		<acc:ManualView x:Name="_manualView" />
    	</TabItem>
    </TabControl>
    In the above code, when the ViewModeId property changes, the new view gets loaded.

  3. #3
    Join Date
    Feb 2001
    Posts
    2,455

    Re: Wpf ??

    Quote Originally Posted by Arjay View Post
    What I've done in this situation is to use a tabcontrol with hidden tabs. As a user makes a 'view' selection, the SelectedIndex of the TabControl is changed and a different view is displayed.

    For example, the following code has the ability to display 3 different views:

    First let's declare the 'hidden' tab control style:
    Code:
    <Window.Resources>
    	<Style x:Key="HiddenTabItemStyle" TargetType="{x:Type TabItem}">
    		<Setter Property="Visibility" Value="Hidden"/>
    		<Setter Property="Margin" Value="0"/>
    	</Style>
    	<Style x:Key="HiddenTabStyle" TargetType="{x:Type TabControl}">
    		<Setter Property="Background" Value="Transparent"/>
    		<Setter Property="Margin" Value="0,-15,0,0"/>
    	</Style>
    </Window.Resources>
    Next use the tabstyles in a tabcontrol that contains 3 different views
    Code:
    <TabControl x:Name="_viewContainer"
    	SelectedIndex="{Binding Path=ViewModeId}"
    	Background="Transparent"
    	Style="{StaticResource HiddenTabStyle}" 	BorderBrush="Transparent" >
    	<TabItem Background="Transparent" Style="{StaticResource HiddenTabItemStyle}">
    		<acc:AutomaticView x:Name="_automaticView" />
    	</TabItem>
    	<TabItem Background="Transparent" Style="{StaticResource HiddenTabItemStyle}">
    		<acc:EditView x:Name="_editView" />
    	</TabItem>
    	<TabItem Background="Transparent" Style="{StaticResource HiddenTabItemStyle}">
    		<acc:ManualView x:Name="_manualView" />
    	</TabItem>
    </TabControl>
    In the above code, when the ViewModeId property changes, the new view gets loaded.
    Arjay,

    Thanks for the reply. So, this is simply to change the views correct? How do you create the views to show? Do you use a UserControl or form without border, or....

    Also, I think I have found another solution as well, ProjectTrackers from CSLA library. Not yet sure which is the better of the two..... In that sample he:

    1) Places a DockPanel on the main window.
    2) Uses a list box with items (TextBlock) as the menu.
    3) In the AXML he attaches (?) a hyperlink which points to a delegate in the main window .cs file.
    4) This delegate then clears the DockPanel and shows the appropriate view.

    The views in this sample are UserControl objects. Just thought you may have 2 cents to put in regarding this method.

    Thanks again,

    Mike B

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,359

    Re: Wpf ??

    Quote Originally Posted by MikeB View Post
    Arjay,

    Thanks for the reply. So, this is simply to change the views correct? How do you create the views to show? Do you use a UserControl or form without border, or....
    Yeah, to create the views you'll see a line such as the following as children of each TabItem:
    Code:
    <acc:AutomaticView x:Name="_automaticView" />
    Those are user controls located in another control library. I actually pass the data context of the main control (which is set to my view model) and pass it to each of the views. This allows me to access the data of my model from each of the views (ie. UserControls).

    Quote Originally Posted by MikeB View Post
    Also, I think I have found another solution as well, ProjectTrackers from CSLA library. Not yet sure which is the better of the two..... In that sample he:

    1) Places a DockPanel on the main window.
    2) Uses a list box with items (TextBlock) as the menu.
    3) In the AXML he attaches (?) a hyperlink which points to a delegate in the main window .cs file.
    4) This delegate then clears the DockPanel and shows the appropriate view.

    The views in this sample are UserControl objects. Just thought you may have 2 cents to put in regarding this method.
    I am familiar with the CSLA framework which btw has had a long history starting with VB, VB.Net, C# and looks like now updated to WPF. The project trackers approach is fine. The approach I've suggested potentially can do all the switching code in xaml (as opposed some wire up in the code behind) which I prefer.

  5. #5
    Join Date
    Feb 2001
    Posts
    2,455

    Re: Wpf ??

    Quote Originally Posted by Arjay View Post
    The approach I've suggested potentially can do all the switching code in xaml (as opposed some wire up in the code behind) which I prefer.
    Well, that makes sence.... I am sure I will have more questions as I dig a little deeper....

    Thanks

    Mike B

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center