Using JavaLongToDateConverter and UrlToImageConverter

1st, in xaml file, add this xmlns entry:
xmlns:ezwpf="clr-namespace:ezwpf.ConvertUtil.Converter;assembly=ConvertUtil"


2nd, declare resources:
<Window.Resources>
        <ezwpf:JavaLongDateConverter x:Key="dateConverter" />
        <ezwpf:UrlToImageConverter x:Key="urlToImageConverter" />
    </Window.Resources>


and use following binding syntax:
//JavaLongDateConverter Sample:
<SomeControl Binding="{Binding targetName, Converter={StaticResource dateConverter},  ConverterParameter=targetName}"/>

//UrlToImageConverter Sample1:
<Image.Source>
         <Binding Converter="{StaticResource urlToImageConverter}"  ConverterParameter="http://your.image.url.png">
         </Binding> 
</Image.Source>

//UrlToImageConverter Sample2, binding a list of image URLs and shows them in a ListBox:
//In this case, your binding target should be a List of some model contains a string property of image url
<ListBox ItemsSource="{Binding YourBindingTarget}">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel IsItemsHost="True"/>
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>
    <DataTemplate>
        <Viewbox>
            <Border BorderThickness="4" BorderBrush="White" Margin="5">
            <Image
                        Width="150"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        Height="150">
                        <Image.Source>
                                    <Binding  Path="YourBindingPath" Converter="{StaticResource urlToImageConverter}" >
                                    </Binding>
                        </Image.Source>
            </Image>
            </Border>
    </Viewbox>
    </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Suggestions & Feedback

If you have any suggestion or feedback, please leave a comment or message on my blog: http://www.mr-fu.net

Last edited Sep 1, 2010 at 11:11 AM by littlefu, version 6

Comments

No comments yet.