Wednesday, March 20, 2013

WPF: How to resize the "RadTileViewItem" in "RadTileView" to the half of ActualWidth of window, while minimizing .

Question: How to resize the “RadTileViewItem” in “RadTileView” to the half of ActualWidth of window, while minimizing.

Solution 1-RenderTransform of FrameworkElement

Using FrameworkElement and setting up RenderTransform to perform the necessary arithmetic/calculations required.
  • Create a “FrameworkElement” and define the transform that will render the actual mathematics behind the scene.
  • By binding the ActualWidth of the page and assembling constants of 0.50, the resultant composite transform has an OffsetX value equal to 1/2 of the page width. 
  • You can try the transform multiplications to assure yourself that's what's happening.
  • Now, bind the “MinimizedColumnWidth” property of RadTileView to FrameworkElement’s OffsetX value which is get calculated as described above.


Solution 2-Converters

<Window.Resources>
<Local:appendKB x:Key="adjustValue"/>
<Window.Resources>
<Setter Property="Width" Value="{Binding Path=ActualWidth, Converter={StaticResource adjustValue}}"/>


Converter Class:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
namespace Simple123
{
public class adjustValue: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double s = (value/2) + 300;
return (s);
}
public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException("ConvertBack should never be called");
}
}
}





No comments:

Post a Comment