How can I bind radiobutton's checked property inside DataTemplate?
This is my DataTemplate:
<DataTemplate x:Key="DataTemplateThemes">
<Grid Width="160" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5,0">
<Grid.RowDefinitions>
<RowDefinition Height="28.3336664835612"/>
<RowDefinition Height="161"/>
<RowDefinition Height="Auto" />
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock x:Name="tbThemeName" HorizontalAlignment="Left" Margin="2" Grid.Row="2" TextWrapping="Wrap"
Text="{Bindi开发者_JAVA百科ng ThemeName}" FontSize="16" FontFamily="Segoe UI" d:LayoutOverrides="Height"/>
<Image Margin="0" Stretch="Fill" Grid.Row="1" Source="{Binding Path=ThemePicName, Converter={StaticResource imageConverter}}"/>
<TextBlock x:Name="tbDescription" HorizontalAlignment="Left" Margin="2" Grid.Row="3"
TextWrapping="Wrap" Text="{Binding ThemeDescription}" FontSize="14.667" FontFamily="Segoe UI"
d:LayoutOverrides="Height"/>
<RadioButton Content="Apply" Margin="-10,0,0,0"
d:LayoutOverrides="Width, Height" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</DataTemplate>
The IsChecked property of RadioButton depends on Theme
property which is available in my ViewModel. Initially I thought I will create a Converter that will pass the current row (datatemplate current DataContext)'s ThemeId and ViewModel's Theme (which is the selected Theme)'s ThemeId property and if they both match I would check the radiobutton. But ConverterParameter cannot take Binding expression as it is not a DependencyProperty. So how do I solve this issue?
Thanks in advance :)
You could implement a multi binding solution. I have previously implemented the solution described here:
http://www.scottlogic.co.uk/blog/colin/2010/05/silverlight-multibinding-solution-for-silverlight-4/
You could then have a converter that accepts the two required parameters.
精彩评论