This is a migrated thread and some comments may be shown as answers.

Localizing RadTileViewItem's header

1 Answer 107 Views
TileView
This is a migrated thread and some comments may be shown as answers.
Kalle
Top achievements
Rank 1
Kalle asked on 07 Aug 2013, 01:01 PM
Hi,

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"
                       Height="14"
                       Margin="0 0 0 0"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Content="X"
                       FontSize="10"
                       Foreground="Black"
                       Background="White"
                       Command="{Binding Path=DataContext.RemoveTileCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
                       CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadTileViewItem}}"
                       Padding="0"
                       />
        <TextBlock x:Name="TileHeader" FontSize="10" Text="{Binding Path=DataContext.DataContext.TileCaption, RelativeSource={RelativeSource AncestorType=telerik:RadTileViewItem}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left"/>
    </StackPanel>
</DataTemplate>

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... 

Br,

Kalle

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 12 Aug 2013, 09:13 AM
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.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
Tags
TileView
Asked by
Kalle
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or