michael nesterenko michael nesterenko - 1 year ago 154
C# Question

wpf card layout

I am very new to wpf. How can I implement CardLayout functionality from java? I have a window where I need completely switch contents depending on user actions, like different tabs in tabbed pane.

Answer Source

You can create multiple pages and host them in a frame. Look here for more information.


<Window x:Class="CardLayout"
        Title="CardLayout" Height="300" Width="300">
        <Frame Height="200" HorizontalAlignment="Left" Margin="12,40,0,0" Name="frame1" VerticalAlignment="Top" Width="254" NavigationUIVisibility="Hidden" />

        <ComboBox HorizontalAlignment="Left" Margin="12,12,0,0" Name="comboBox1" VerticalAlignment="Top" Width="254" SelectedIndex="0" SelectionChanged="comboBox1_SelectionChanged">

Code Behind:

public partial class CardLayout : Window
    private Page[] pages = new Page[] {new Page1(), new Page2()};

    public CardLayout()

    private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        frame1.Content = pages[((ComboBox) sender).SelectedIndex];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download