Hi, I am currently defining few grids as following:
<Grid.RowDefinitions>
<RowDefinition Height="{TemplateBinding Height-Height/5}"/>
<RowDefinition Height="{TemplateBinding Height/15}"/>
<RowDefinition Height="{TemplateBinding Height/20}"/>
<RowDefinition Height="{TemplateBinding Height/6}"/>
</Grid.RowDefinitions>
While the division works fine , the subtraction isn't yielding the output.
Ialso tried like following:
<RowDefinition Height="{TemplateBinding Height-(Height/5)}"/>
Still no result. Any suggestions plz.
Thanks, Subhen
**
Update
** Now In My XAML I tried implementing the IvalueConverter like :
<RowDefinition Height="{TemplateBinding Height, Converter={StaticResource heightConverter}}"/>
Added the reference as
<local:medieElementHeight x:Key="heightConverter"/>
In side generic.cs I have coded as following:
public class medieElementHeight : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
//customVideoControl objVdeoCntrl=new customVideoControl();
double custoMediaElementHeight = (double)value;//objVdeoCntrl.customMediaPlayer.Height;
double mediaElementHeight = custoMediaElementHeight - (custoMediaElementHeight / 5);
return mediaElementHeight;
}
#region IValueConverter Members
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
But getting the exception Unknown Element Height in the element RowDefination.
Updating Code @Tony
<Style TargetType="local:customVideoControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:customVideoControl">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="{TemplateBinding Height-Height/5}"/>
<RowDefinition Height="{TemplateBinding Height/15}"/>
<RowDefinition Height="{TemplateBinding Height/20}"/>
<RowDefinition Height="{TemplateBinding Height/6}"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<MediaElement x:Name="customMediaPlayer"
Source="{TemplateBinding CustomMediaSource}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Height="{TemplateBinding Height}"
Width="{TemplateBinding Width}"
Grid.Row="0" Grid.ColumnSpan="3"
/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Now , My implementing XAML file contains is as follows:
<customMediaElement:customVideoControl x:Name="custMediaElement" Width="400" Height="300" nextBtnEvent="custMediaElement_nextBtnEvent" prevBtnEvent="custMediaElement_prevBtnEvent" Visibility="Collapsed"/>
Now, I want to substract or divide the values depending on the height of custMediaElement.