How to use namespaces in XAML WPF including to refer to a converter (maybe other code too)

Place in header part of file. My initial mistake was
    xmlns:local="clr-namespace:MyConverters
Should have been
    xmlns:local="clr-namespace:OneWay.WPF.MyConverters
Need to include the assembly, even if it is the same project.
In this code local gives the namespace a short name.

Next using the namespace in XAML

<Style.Resources>
    <local:ButtonCenterConverter x:Key=”DivideByTwo”></local:ButtonCenterConverter>
</Style.Resources>

How to do Animation in WPF

 

How to extract an animation to a resource by using style
Also How to perform a scale transform in XAML

<ResourceDictionary xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns
:x=”http://schemas.microsoft.com/winfx/2006/xaml”&gt;

<Style TargetType=”Button”>
<Style.Triggers>
<EventTrigger RoutedEvent=”Button.MouseEnter”>
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty=”(RenderTransform).ScaleTransform.ScaleX)” To=”1.1″ Duration=”0:0:0.15″ />
<!–AutoReverse=”True” RepeatBehavior=”2x”–>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty=”(RenderTransform).(ScaleTransform.ScaleY)” To=”1.1″ Duration=”0:0:0.15″ />

<!–<DoubleAnimation

Storyboard.TargetName=”GrowingButton”
Storyboard.TargetProperty=”Button.Height” To=”80″ Duration=”0:0:0.2″ />–>

</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent=”Button.MouseLeave”>
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty=”(RenderTransform).(ScaleTransform.ScaleX)” To=”1.0″Duration=”0:0:0.15″ />

<!–AutoReverse=”True” RepeatBehavior=”2x”–></Storyboard></BeginStoryboard>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty=”(RenderTransform).(ScaleTransform.ScaleY)” To=”1.0″ Duration=”0:0:0.15″ />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
<Setter Property=”RenderTransform”>
<Setter.Value>
<ScaleTransform
ScaleX=”1″ ScaleY=”1″
CenterX=”50″CenterY=”10″
/>
<!–CenterX=”{Binding Path=ActualWidth, ElementName=Button,Converter=}”–>
</Setter.Value>
</Setter>
</Style>
 

How to override a global style

Use Style=”{x:Null}”

How to perform a procedurally animated growing buttons using a scale transform

See Wrox VB2010 p214

How to perform XAML animation: First Success

             <Button Content=”Load” HorizontalAlignment=”Left” Name=”LoadButton” VerticalAlignment=”Top” Width=”75″ >
                <Button.Triggers>
                    <EventTrigger RoutedEvent=”Button.MouseEnter”>
                        <EventTrigger.Actions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetName=”LoadButton”
                                        Storyboard.TargetProperty=”Opacity” From=”1.0″ To=”0.0″ Duration=”0:0:1″ AutoReverse=”True” RepeatBehavior=”Forever” />
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger.Actions>
                    </EventTrigger>
                </Button.Triggers>
            </Button>

         <Button Content=”Growing” HorizontalAlignment=”Left” Margin=”479,4,0,0″ Name=”GrowingButton” VerticalAlignment=”Top” Width=”75″ >
            <Button.Triggers>
                <EventTrigger RoutedEvent=”Button.MouseEnter”>
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation
                                        Storyboard.TargetName=”GrowingButton”
                                        Storyboard.TargetProperty=”Width” To=”80″ Duration=”0:0:0.5″ AutoReverse=”True” RepeatBehavior=”2x” />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Button.Triggers>
        </Button>>

How to use Application.Resources and also ResourceDictionaries in WPF

Application.Resources

The help page in MSDN is at:

http://msdn.microsoft.com/en-us/library/ms746624.aspx?lc=1033

I originally got this wrong, by trying to create a new Resource dictionary and placing the XAML <Application.Resources> into this new file.
When you create a new WPF application, an Application.xaml file is created automatically. This already contains an <Application.Resources> section, so just add in your new resources direct into here.

How to use Resource Dictionaries

Create Resource Dictionary, possibly putting it in a different folder, perhaps named Assets.
Then in Application.xaml

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source=”Assets\Dictionary1.xaml” />
<ResourceDictionary Source=”Assets\Dictionary2.xaml” />
</ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
</Application.Resources>

<–Seem to be only able use Resoure Dictionary or Application.Resources not a mix of both
So Following line is invalid, because of following ResourceDictionaries
May be possible if a Key is used somewhere>–>
<!–<Brush x:Key=”myColorYellow”>Yellow</Brush>–>

Error 1

If on a window or page and “The designer does not support loading dictionaries that mix “ResourceDictionary” items without a key and other items in the same collection”

Solution 1:

Put the other resources inside the ResourceDictionary even if they are designed there.

With thanks to http://stackoverflow.com/questions/3818000/how-to-define-resources-and-a-mergedictionary-with-a-key-in-a-sl4-page

How to store Resource Dictionaries in a separate assembly and use them

In the following example of use. RDL01 is an external assembly. The word “component” is there as seen here.

<StackPanel>
<StackPanel.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source=”/RDL01;component/Dictionary1.xaml”></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</StackPanel.Resources>
<Button Content=”Hello” Width=”100″ Height=”50″></Button>
</StackPanel>

How to use the Property Windows for controls to use and extract Resources

Use extract value to resource

WPF Format Date in ListView

 
I am very new to WPF. So here goes:

<GridViewColumn Header=“Date Input” Width=“150”>
<GridViewColumn.CellTemplate >
<DataTemplate >
<TextBox Text=“{Binding Path=DateInput, StringFormat=’dd-MMM-yy’}” />
</DataTemplate>
</GridViewColumn.CellTemplate></GridViewColumn>

 
Good article here…