Click here to Skip to main content
15,897,273 members
Articles / Desktop Programming / WPF

Composite Application Library in WPF Application

Rate me:
Please Sign up or sign in to vote.
4.82/5 (30 votes)
2 Mar 2009CPOL8 min read 95.8K   3.1K   110  
WPF application built on the Composite Application Library. How to start, organize solution projects, distribute resources and build complex UI using the Presentation Model pattern.
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctl="clr-namespace:CWA.UIControls;assembly=CWA.UIControls">

    <!--ImageRadioButton Style-->
    
    <Style TargetType="{x:Type ctl:ImageRadioButton}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctl:ImageRadioButton}">
                    <Grid>
                        <Border Name="OuterBorder" BorderThickness="1" MinWidth="80"
                                BorderBrush="{DynamicResource ImageButtonOuterBorderBrush}" 
                                Background="{DynamicResource ImageButtonBackgroundBrush}"
                                CornerRadius="3" Margin="1,3,1,3" SnapsToDevicePixels="True">
                            <Border Name="InnerBorder" BorderThickness="1" CornerRadius="2" 
                                    SnapsToDevicePixels="True" BorderBrush="{DynamicResource ImageButtonInnerBorderBrush}" >
                                <Grid Name="Glow" Background="Transparent">
                                    <Border Padding="12,5,12,5">
                                        <StackPanel Orientation="Horizontal">
                                            <Image Name="Icon" RenderOptions.BitmapScalingMode="NearestNeighbor" 
                                                    Source="{TemplateBinding Icon}" Stretch="None" Margin="0,0,4,0" />
                                            <ContentPresenter
                                                    TextBlock.Foreground="{TemplateBinding Foreground}" 
                                                    Content="{TemplateBinding ContentControl.Content}" 
                                                    VerticalAlignment="Center" />
                                        </StackPanel>
                                    </Border>
                                </Grid>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Icon" Value="{x:Null}">
                            <Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource ImageButtonOuterBorderBrushOver}" />
                            <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource ImageButtonBackgroundBrushOver}" />
                            <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource ImageButtonInnerBorderBrushOver}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource ImageButtonOuterBorderBrushOver}" />
                            <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource ImageButtonBackgroundBrushOver}" />
                            <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource ImageButtonInnerBorderBrushOver}" />
                            <Setter TargetName="Glow" Property="Background" Value="{DynamicResource ImageButtonGlowBrushPressed}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource ImageButtonOuterBorderBrushPressed}" />
                            <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource ImageButtonBackgroundBrushPressed}" />
                            <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource ImageButtonInnerBorderBrushPressed}" />
                            <Setter TargetName="Glow" Property="Background" Value="{DynamicResource ImageButtonGlowBrushChecked}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="TextBlock.Foreground" Value="{DynamicResource DisabledForegroundBrush}" />
                            <Setter TargetName="Icon" Property="Opacity" Value="0.4" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>

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 Code Project Open License (CPOL)


Written By
Latvia Latvia
Jevgenij lives in Riga, Latvia. He started his programmer's career in 1983 developing software for radio equipment CAD systems. Created computer graphics for TV. Developed Internet credit card processing systems for banks.
Now he is System Analyst in Accenture.

Comments and Discussions