Note that there are some explanatory texts on larger screens.

plurals
  1. POCan we manipulate (subtract) the value of a property while template bidning?
    text
    copied!<p>I am currently defining few grids as following:</p> <pre><code>&lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="{TemplateBinding Height-Height/5}"/&gt; &lt;RowDefinition Height="{TemplateBinding Height/15}"/&gt; &lt;RowDefinition Height="{TemplateBinding Height/20}"/&gt; &lt;RowDefinition Height="{TemplateBinding Height/6}"/&gt; &lt;/Grid.RowDefinitions&gt; </code></pre> <p>While the division works fine , the subtraction isn't yielding the output.</p> <p>Ialso tried like following:</p> <pre><code>&lt;RowDefinition Height="{TemplateBinding Height-(Height/5)}"/&gt; </code></pre> <p>Still no result. Any suggestions plz.</p> <p>Thanks, Subhen</p> <p>**</p> <h2>Update</h2> <p>** Now In My XAML I tried implementing the IvalueConverter like :</p> <pre><code>&lt;RowDefinition Height="{TemplateBinding Height, Converter={StaticResource heightConverter}}"/&gt; </code></pre> <p>Added the reference as </p> <pre><code>&lt;local:medieElementHeight x:Key="heightConverter"/&gt; </code></pre> <p>In side generic.cs I have coded as following:</p> <pre><code>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 } </code></pre> <p>But getting the exception Unknown Element Height in the element RowDefination.</p> <p><strong>Updating Code <em>@Tony</em></strong></p> <pre><code>&lt;Style TargetType="local:customVideoControl"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="local:customVideoControl"&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="{TemplateBinding Height-Height/5}"/&gt; &lt;RowDefinition Height="{TemplateBinding Height/15}"/&gt; &lt;RowDefinition Height="{TemplateBinding Height/20}"/&gt; &lt;RowDefinition Height="{TemplateBinding Height/6}"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="2*"/&gt; &lt;ColumnDefinition Width="2*"/&gt; &lt;ColumnDefinition Width="2*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;MediaElement x:Name="customMediaPlayer" Source="{TemplateBinding CustomMediaSource}" HorizontalAlignment="Center" VerticalAlignment="Center" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" Grid.Row="0" Grid.ColumnSpan="3" /&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>Now , My implementing XAML file contains is as follows:</p> <pre><code>&lt;customMediaElement:customVideoControl x:Name="custMediaElement" Width="400" Height="300" nextBtnEvent="custMediaElement_nextBtnEvent" prevBtnEvent="custMediaElement_prevBtnEvent" Visibility="Collapsed"/&gt; </code></pre> <p>Now, I want to substract or divide the values depending on the height of custMediaElement.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload