Click here to Skip to main content
15,885,757 members
Articles / Desktop Programming / WPF

Conceptual Children: A powerful new concept in WPF

Rate me:
Please Sign up or sign in to vote.
5.00/5 (34 votes)
6 Apr 2008BSD32 min read 218.4K   3.2K   122  
This article describes a new approach by which an element can remove its visual and logical relationships to its children while maintaining a conceptual parental relationship with those children.
<Window
  x:Class="WpfDiscipleBlogViewer3D.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:WpfDiscipleBlogViewer3D"
  FontWeight="Bold" FontSize="18"
  FocusManager.IsFocusScope="False"
  Title="WPF Disciples :: Blogroll"
  Width="800" Height="800"
  WindowStartupLocation="CenterScreen"
  >
  <Window.Background>
    <ImageBrush ImageSource="images/background.jpg" />
  </Window.Background>

  <Window.CommandBindings>
    <CommandBinding 
      Command="Open" 
      CanExecute="Open_CanExecute" 
      Executed="Open_Executed" 
      />
  </Window.CommandBindings>

  <DockPanel Margin="4">
    <DockPanel.DataContext>
      <XmlDataProvider Source="blogroll.xml" XPath="blogs/blog" />
    </DockPanel.DataContext>

    <!-- NAVIGATION BUTTONS -->
    <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Center" Margin="0,0,0,4" Orientation="Horizontal">
      <StackPanel.Resources>
        <ResourceDictionary Source="GelButtonStyle.xaml" />
      </StackPanel.Resources>

      <RepeatButton Click="PageBackButtonClicked" Content="|&lt;&lt;" />
      <Rectangle Width="10" />
      <RepeatButton Click="MoveBackButtonClicked" Content="&lt;&lt;" />
      <Rectangle Width="10" />
      <RepeatButton Click="MoveForwardButtonClicked" Content="&gt;&gt;" />
      <Rectangle Width="10" />
      <RepeatButton Click="PageForwardButtonClicked" Content="&gt;&gt;|" />
    </StackPanel>

    <!-- BLOGGER IMAGE CAROUSEL -->
    <ListBox x:Name="Carousel" Background="Transparent" BorderBrush="Transparent" ItemsSource="{Binding}" Focusable="False" IsSynchronizedWithCurrentItem="True">
      <!-- 
        Tell the ItemsControl to use our custom
        3D layout panel to arrage its items.
        -->
      <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
          <local:Panel3D Loaded="OnPanel3DLoaded" />
        </ItemsPanelTemplate>
      </ListBox.ItemsPanel>

      <ListBox.ItemContainerStyle>
        <Style TargetType="{x:Type ListBoxItem}">
          <Setter Property="HorizontalContentAlignment" Value="Stretch" />
          <Setter Property="Width" Value="200" />
          <Setter Property="Height" Value="200" />
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type ListBoxItem}">
                <ContentPresenter ContentSource="Content" />
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </ListBox.ItemContainerStyle>

      <!-- Explain how to render a BitmapImage. -->
      <ListBox.ItemTemplate>
        <DataTemplate>
          <Button
              Command="Open"
              CommandParameter="{Binding XPath=@url}"
              Cursor="Hand"
              Focusable="False"
              >
            <Button.Template>
              <ControlTemplate TargetType="Button">
                <Border
                    Background="Black"
                    BorderBrush="#88000000"
                    BorderThickness="0.5"
                    Padding="1"
                    >
                  <DockPanel>
                    <Button
                        Background="Transparent"             
                        Command="Open"
                        CommandParameter="{Binding XPath=@bio}"
                        Content="{Binding XPath=@author}"
                        DockPanel.Dock="Top"
                        Focusable="False"
                        Foreground="White"
                        HorizontalAlignment="Stretch"
                        Margin="-14,-8,-12,8"
                        ToolTip="Read author's bio"
                        />
                    <Image Source="{Binding XPath=@pic}" />
                  </DockPanel>
                </Border>
              </ControlTemplate>
            </Button.Template>
          </Button>
        </DataTemplate>
      </ListBox.ItemTemplate>
    </ListBox>

  </DockPanel>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The BSD License


Written By
United States United States
Dr. WPF is a WPF Disciple! Check out the doctor's blog and bio for more information.

Comments and Discussions