Localizing RadTileViewItem's header

2 posts, 0 answers
  1. Kalle
    Kalle avatar
    26 posts
    Member since:
    Feb 2013

    Posted 07 Aug 2013 Link to this post


    This is not 100% RadTileView/Item specific stuff but still would probably require different kind of implementation for RadTileViewItem templates...

    I'm currently using headerTemplate like below as my RadTileView's ItemTemplate:

    <DataTemplate x:Key="headerTemplate">
        <StackPanel Orientation="Horizontal">
            <telerik:RadButton Width="14"
                           Margin="0 0 0 0"
                           Command="{Binding Path=DataContext.RemoveTileCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
                           CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadTileViewItem}}"
            <TextBlock x:Name="TileHeader" FontSize="10" Text="{Binding Path=DataContext.DataContext.TileCaption, RelativeSource={RelativeSource AncestorType=telerik:RadTileViewItem}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left"/>

    I have a problem localizing this TileHeader because TileCaption is a string property in each Tile's ViewModel and it gets a value like "Amount: 0" or "Not set" depending on the situation. So the localized part of the property should be "Amount: " or "Not set" or nothing in some cases.

    I'm using 3rd party localization addon called WPF Localization extension and localization is done with binding like Text="lex:Loc SomeKey" so basically what I'm asking is how could I make Tile specific ItemTemplate so that I can use data binding to desired localized key or what would be the best way to accomplish binding to TileViewItem so that it will get the change notification and updates accordingly?

    My current implementation lacks the functionality to refresh the title when RaisePropertyChanged is triggered (when language is changed) because I don't have data binding to TileCaption (I'm setting the value of TileCaption property in code).

    So if I could somehow make tile specific ItemTemplate for each tile I could make binding in XAML. Of course this has other problem because I need to have 2 different localizations depending on the situation but at least the change notification would work.

    Or should I create databindings in code-behind... 


  2. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1167 posts

    Posted 12 Aug 2013 Link to this post

    Hi Kalle,

    I am not sure why the change notification does not apply to your UI. If you can provide me with scaled down project I can take a closer look into your implementation and try to find the reasons behind the current behavior. Basically, if you rice the property changed notification when you manually update the TileCaption property the UI should respect that change due to the TwoWay binding. Please note that you need to rise the event for the specific item (holding that property).

    On the other hand, in order to create specific ItemTemplate for each RadTileViewItem you can use the ItemTemplateSelector property of the RadTileView control. By following this approach you will be allowed to set the template of each item depending on custom logic implemented in the template selector class.

    Please give this approach a try and let me know if you need any further assistance.

    Pavel R. Pavlov
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
Back to Top