
Teste Video

InertiaScrollViewer – ScrollViewer com inercia! (UPDATED)
Março 13, 2009Aqui fica o novo codigo do InertiaScrollViewer, tem algumas melhorias principalmente em termos de performance.
public class InertiaScrollViewer : ScrollViewer
{
DispatcherTimer _yourTimer;
public InertiaScrollViewer()
{
_yourTimer = new DispatcherTimer(DispatcherPriority.Normal);
_yourTimer.Interval = TimeSpan.FromMilliseconds(10);
_yourTimer.Tick += new EventHandler(yourTimer_Tick);
this.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
this.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
}
#region Overrides
protected override void OnPreviewMouseDown(System.Windows.Input.MouseButtonEventArgs e)
{
Point mouseposition = e.GetPosition(this);
InertiaScrollViewer.SetIsDragging(this, true);
InertiaScrollViewer.SetTargetX(this, mouseposition.X * -1);
InertiaScrollViewer.SetTargetY(this, mouseposition.Y * -1);
double offsetx = this.HorizontalOffset + mouseposition.X;
double offsety = this.VerticalOffset + mouseposition.Y;
InertiaScrollViewer.SetOffset(this, new Point(offsetx, offsety));
_yourTimer.Start();
base.OnMouseDown(e);
}
protected override void OnMouseUp(System.Windows.Input.MouseButtonEventArgs e)
{
Point mouseposition = e.GetPosition(this);
InertiaScrollViewer.SetTargetX(this, (mouseposition.X) * -1);
InertiaScrollViewer.SetTargetY(this, (mouseposition.Y) * -1);
InertiaScrollViewer.SetIsDragging(this, false);
base.OnMouseUp(e);
}
protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)
{
InertiaScrollViewer.SetIsDragging(this, false);
base.OnMouseLeave(e);
}
protected override void OnPreviewMouseMove(System.Windows.Input.MouseEventArgs e)
{
if (!CanDrag && (InertiaScrollViewer.GetIsDragging(this) == true))
{
Point mouseposition = e.GetPosition(this);
InertiaScrollViewer.SetTargetX(this, (mouseposition.X) * -1);
InertiaScrollViewer.SetTargetY(this, (mouseposition.Y) * -1);
_yourTimer.Start();
}
base.OnMouseMove(e);
}
#endregion
private void yourTimer_Tick(object sender, EventArgs e)
{
if (!CanDrag)
{
this.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
this.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
if (InertiaScrollViewer.GetIsDragging(this))
{
double oldX = this.HorizontalOffset;
double oldY = this.VerticalOffset;
this.ScrollToVerticalOffset(this.VerticalOffset + (((InertiaScrollViewer.GetTargetY(this) + InertiaScrollViewer.GetOffset(this).Y) - this.VerticalOffset) * .3));
this.ScrollToHorizontalOffset(this.HorizontalOffset + ((InertiaScrollViewer.GetTargetX(this) + InertiaScrollViewer.GetOffset(this).X) - this.HorizontalOffset) * .3);
InertiaScrollViewer.SetVelocityX(this, (this.HorizontalOffset + ((InertiaScrollViewer.GetTargetX(this) + InertiaScrollViewer.GetOffset(this).X) - this.HorizontalOffset) * .3) - oldX);
InertiaScrollViewer.SetVelocityY(this, (this.VerticalOffset + (((InertiaScrollViewer.GetTargetY(this) + InertiaScrollViewer.GetOffset(this).Y) - this.VerticalOffset) * .3)) - oldY);
}
else
{
this.ScrollToHorizontalOffset(this.HorizontalOffset + InertiaScrollViewer.GetVelocityX(this));
this.ScrollToVerticalOffset(this.VerticalOffset + InertiaScrollViewer.GetVelocityY(this));
InertiaScrollViewer.SetVelocityX(this, InertiaScrollViewer.GetVelocityX(this) * VelocityConst);
InertiaScrollViewer.SetVelocityY(this, InertiaScrollViewer.GetVelocityY(this) * VelocityConst);
}
}
if ((Math.Abs(Math.Round(InertiaScrollViewer.GetVelocityX(this), 1)) == 0.0
&& Math.Abs(Math.Round(InertiaScrollViewer.GetVelocityY(this), 1)) == 0.0)
|| (this.ScrollableHeight==this.VerticalOffset && this.ScrollableWidth==this.HorizontalOffset)
|| (0 == this.VerticalOffset && 0 == this.HorizontalOffset))
{
_yourTimer.Stop();
this.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
this.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
}
}
#region Properties
#region TargetX
public static double GetTargetX(DependencyObject obj)
{
return (double)obj.GetValue(TargetXProperty);
}
public static void SetTargetX(DependencyObject obj, double value)
{
obj.SetValue(TargetXProperty, value);
}
// Using a DependencyProperty as the backing store for TargetX. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TargetXProperty =
DependencyProperty.Register("TargetX", typeof(double), typeof(InertiaScrollViewer), new UIPropertyMetadata(0.0));
#endregion
#region TargetY
public static double GetTargetY(DependencyObject obj)
{
return (double)obj.GetValue(TargetYProperty);
}
public static void SetTargetY(DependencyObject obj, double value)
{
obj.SetValue(TargetYProperty, value);
}
// Using a DependencyProperty as the backing store for TargetY. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TargetYProperty =
DependencyProperty.Register("TargetY", typeof(double), typeof(InertiaScrollViewer), new UIPropertyMetadata(0.0));
#endregion
#region Offset
public static Point GetOffset(DependencyObject obj)
{
return (Point)obj.GetValue(OffsetProperty);
}
public static void SetOffset(DependencyObject obj, Point value)
{
obj.SetValue(OffsetProperty, value);
}
// Using a DependencyProperty as the backing store for Offset. This enables animation, styling, binding, etc...
public static readonly DependencyProperty OffsetProperty =
DependencyProperty.Register("Offset", typeof(Point), typeof(InertiaScrollViewer), new UIPropertyMetadata(new Point(0, 0)));
#endregion
#region Velocity
public static double GetVelocityX(DependencyObject obj)
{
return (double)obj.GetValue(VelocityXProperty);
}
public static void SetVelocityX(DependencyObject obj, double value)
{
obj.SetValue(VelocityXProperty, value);
}
// Using a DependencyProperty as the backing store for VelocityX. This enables animation, styling, binding, etc...
public static readonly DependencyProperty VelocityXProperty =
DependencyProperty.RegisterAttached("VelocityX", typeof(double), typeof(InertiaScrollViewer), new UIPropertyMetadata(0.0));
public static double GetVelocityY(DependencyObject obj)
{
return (double)obj.GetValue(VelocityYProperty);
}
public static void SetVelocityY(DependencyObject obj, double value)
{
obj.SetValue(VelocityYProperty, value);
}
// Using a DependencyProperty as the backing store for VelocityY. This enables animation, styling, binding, etc...
public static readonly DependencyProperty VelocityYProperty =
DependencyProperty.Register("VelocityY", typeof(double), typeof(InertiaScrollViewer), new UIPropertyMetadata(0.0));
public double VelocityConst
{
get { return (double)GetValue(VelocityConstProperty); }
set { SetValue(VelocityConstProperty, value); }
}
// Using a DependencyProperty as the backing store for VelocityConst. This enables animation, styling, binding, etc...
public static readonly DependencyProperty VelocityConstProperty =
DependencyProperty.Register("VelocityConst", typeof(double), typeof(InertiaScrollViewer), new UIPropertyMetadata(0.97));
#endregion
#region IsDragging
public static bool GetIsDragging(DependencyObject obj)
{
return (bool)obj.GetValue(IsDraggingProperty);
}
public static void SetIsDragging(DependencyObject obj, bool value)
{
obj.SetValue(IsDraggingProperty, value);
}
// Using a DependencyProperty as the backing store for IsDragging. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsDraggingProperty =
DependencyProperty.Register("IsDragging", typeof(bool), typeof(InertiaScrollViewer), new UIPropertyMetadata(false));
#endregion
public bool CanDrag
{
get { return (bool)GetValue(CanDragProperty); }
set { SetValue(CanDragProperty, value); }
}
// Using a DependencyProperty as the backing store for CanDrag. This enables animation, styling, binding, etc...
public static readonly DependencyProperty CanDragProperty =
DependencyProperty.Register("CanDrag", typeof(bool), typeof(InertiaScrollViewer), new UIPropertyMetadata(false));
#endregion
}
Até breve,
Miguel Duarte

InertiaListBox – ListBox com inercia!!!
Março 13, 2009Com o InertiaScrollViewer que podem encontrar mais abaixo tinhamos um problema ao usa-lo numa ListBox devido aos eventos do Selector, para isso resolvi criar esta classe que nos permite ter o mesmo comportamento mas agora com uma ListBox.
Portanto, cá esta o código do .cs
[TemplatePart(Name = "PART_Scroll", Type = typeof(InertiaScrollViewer))]
public class InertiaListBox : ListBox
{
#region Declara-se que
private SelectionChangedEventArgs _selectionChangedEventArgs;
private Point _offset;
private Point _mouseDown;
List<object> _oldSelecteds;
#endregion
static InertiaListBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(InertiaListBox), new FrameworkPropertyMetadata(typeof(InertiaListBox)));
}
public InertiaListBox()
{
_offset = new Point(0.0, 0.0);
_selectionChangedEventArgs = null;
_oldSelecteds = new List<object>();
this.PreviewMouseDown += new MouseButtonEventHandler(InertiaListBox_PreviewMouseDown);
Style _styleItems = new Style(typeof(ListBoxItem));
TemplateBindingExtension b=new TemplateBindingExtension(InertiaListBox.IsSelectedProperty);
_styleItems.Setters.Add(new Setter(Selector.IsSelectedProperty,b));
}
#region Eventos
void InertiaListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
_offset = new Point((this.Template.FindName("PART_Scroll", this) as InertiaScrollViewer).HorizontalOffset,
(this.Template.FindName("PART_Scroll", this) as InertiaScrollViewer).VerticalOffset);
_mouseDown = new Point(Mouse.GetPosition(this).X + _offset.X,
Mouse.GetPosition(this).Y + _offset.Y);
}
#endregion
#region Auxiliar
private void SetIsSelected(SelectionChangedEventArgs e)
{
foreach (var item in _oldSelecteds)
{
InertiaListBox.SetIsSelected(this.ItemContainerGenerator.ContainerFromItem(item), false);
}
_oldSelecteds = new List<object>();
if (e != null)
{
foreach (var item in e.AddedItems)
{
_oldSelecteds.Add(item);
InertiaListBox.SetIsSelected(this.ItemContainerGenerator.ContainerFromItem(item), true);
}
}
}
#endregion
#region Overrides
protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
{
Point _mouseUp = new Point(Mouse.GetPosition(this).X + _offset.X,
Mouse.GetPosition(this).Y + _offset.Y);
if (_selectionChangedEventArgs != null)
{
switch (Orientation)
{
case Orientation.Horizontal:
if (Math.Abs(_mouseUp.X - _mouseDown.X) < 2)
{
SetIsSelected(_selectionChangedEventArgs);
base.OnSelectionChanged(_selectionChangedEventArgs);
_selectionChangedEventArgs = null;
}
break;
case Orientation.Vertical:
if (Math.Abs(_mouseUp.Y - _mouseDown.Y) < 2)
{
SetIsSelected(_selectionChangedEventArgs);
base.OnSelectionChanged(_selectionChangedEventArgs);
_selectionChangedEventArgs = null;
}
break;
default:
break;
}
}
base.OnMouseUp(e);
}
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
{
_selectionChangedEventArgs = e;
}
#endregion
#region Properties
public static new bool GetIsSelected(DependencyObject obj)
{
return (bool)obj.GetValue(IsSelectedProperty);
}
public static new void SetIsSelected(DependencyObject obj, bool value)
{
obj.SetValue(IsSelectedProperty, value);
}
// Using a DependencyProperty as the backing store for IsSelected. This enables animation, styling, binding, etc...
public static new readonly DependencyProperty IsSelectedProperty =
DependencyProperty.RegisterAttached("IsSelected", typeof(bool), typeof(InertiaListBox), new UIPropertyMetadata(false));
public Orientation Orientation
{
get { return (Orientation)GetValue(OrientationProperty); }
set { SetValue(OrientationProperty, value); }
}
// Using a DependencyProperty as the backing store for Orientation. This enables animation, styling, binding, etc...
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register("Orientation", typeof(Orientation), typeof(InertiaListBox), new UIPropertyMetadata(Orientation.Vertical));
#endregion
}
O template onde usamos o InertiaSrollviewer
<Style TargetType="{x:Type local:InertiaListBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:InertiaListBox}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<local:InertiaScrollViewer Focusable="False" x:Name="PART_Scroll">
<StackPanel Orientation="{TemplateBinding Orientation}" IsItemsHost="True" />
</local:InertiaScrollViewer>
</Border>
</ControlTemplate
</Setter.Value>
</Setter>
</Style>
A partir de agora e sempre que quisermos usa-la, basta definir o ItemTemplate ou o Style para ListBoxItem, por exemplo
<local:InertiaListBox Orientation="Vertical">
<local:InertiaListBox.Resources>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<TextBlock x:Name="mov" Text="{Binding .}"/>
<ControlTemplate.Triggers>
<Trigger Property="local:InertiaListBox.IsSelected" Value="True">
<Setter Property="Background" TargetName="mov" Value="Blue"/>
<Setter Property="Foreground" TargetName="mov" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
</Style.Triggers>
</Style>
</local:InertiaListBox.Resources>
</local:InertiaListBox>
Para já é tudo, confiram os updates ao InertiaScrollViewer ![]()
Até breve,
Miguel Duarte

FiveStarRating WPF
Março 5, 2009Boas!
Deixo-vos aqui um pequeno controlo que desenvolvi para podermos facilmente transformar qualquer pontuação numa Five Star Rating
Para isso basta definir as propriedades Value e Maximum e automaticamente temos uma FiveStarRating.
public class FiveStarRating : ProgressBar
{
static FiveStarRating()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(FiveStarRating), new FrameworkPropertyMetadata(typeof(FiveStarRating)));
}
#region Properties
public Brush FrontStarBackground
{
get { return (Brush)GetValue(FrontStarBackgroundProperty); }
set { SetValue(FrontStarBackgroundProperty, value); }
}
// Using a DependencyProperty as the backing store for FrontStarBackground. This enables animation, styling, binding, etc...
public static readonly DependencyProperty FrontStarBackgroundProperty =
DependencyProperty.Register("FrontStarBackground", typeof(Brush), typeof(FiveStarRating), new UIPropertyMetadata(Brushes.YellowGreen));
#endregion
}
Como podem verificar o controlo deriva de uma progressbar.
Precisamos também deste converter
public class ConvertValue:IMultiValueConverter
{
#region IMultiValueConverter Members
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double value = double.Parse(values[0].ToString());
double maximum = double.Parse(values[1].ToString());
double actualWidth = double.Parse(values[2].ToString());
return value * actualWidth / maximum;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
#endregion
}
E finalmente o template para o control
<local:ConvertValue x:Key="ConvertValue"/>
<Style TargetType="{x:Type local:FiveStarRating}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:FiveStarRating}">
<Border
BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<StackPanel Orientation="Horizontal" x:Name="_panelDark" HorizontalAlignment="Left">
<Path Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >
</Path>
<Path Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >
</Path>
<Path Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >
</Path>
<Path Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >
</Path>
<Path Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >
</Path>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" x:Name="_panelLight" HorizontalAlignment="Left">
<StackPanel.MaxWidth>
<MultiBinding Converter="{StaticResource ConvertValue}">
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum"/>
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ActualWidth"/>
</MultiBinding>
</StackPanel.MaxWidth>
<Path Fill="{TemplateBinding FrontStarBackground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >
</Path>
<Path Fill="{TemplateBinding FrontStarBackground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >
</Path>
<Path Fill="{TemplateBinding FrontStarBackground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >
</Path>
<Path Fill="{TemplateBinding FrontStarBackground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >
</Path>
<Path Fill="{TemplateBinding FrontStarBackground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Data="M11.490234,6.0883789 C11.576172,6.0883789 11.633463,6.1179199 11.662109,6.177002 C11.676433,6.206543 11.704184,6.3016562 11.745361,6.4623413 C11.786539,6.6230268 11.841146,6.8492842 11.90918,7.1411133 L12.376465,9.1391602 L14.41748,8.9672852 C14.703938,8.9440107 14.920572,8.9265547 15.067383,8.914917 C15.214192,8.9032803 15.291178,8.8974609 15.29834,8.8974609 C15.387857,8.8974609 15.454996,8.916708 15.499756,8.9552002 C15.544515,8.9936934 15.566895,9.0514326 15.566895,9.128418 C15.566895,9.189291 15.548991,9.2367344 15.513184,9.270752 C15.495279,9.2877607 15.417847,9.3412476 15.280884,9.4312134 C15.143921,9.5211792 14.947428,9.647624 14.691406,9.8105469 L12.972656,10.911621 L14.07373,13.672363 C14.088053,13.701009 14.095215,13.743978 14.095215,13.80127 C14.095215,13.85498 14.075521,13.90153 14.036133,13.940918 C13.996744,13.980306 13.953775,14 13.907227,14 C13.864258,14 13.819498,13.984782 13.772949,13.954346 C13.749675,13.939127 13.674927,13.878479 13.548706,13.7724 C13.422485,13.666321 13.244792,13.514811 13.015625,13.317871 L11.490234,11.996582 L9.9863281,13.296387 C9.75,13.500488 9.5671587,13.657369 9.4378052,13.767029 C9.3084507,13.876688 9.232584,13.939127 9.2102051,13.954346 C9.1654463,13.984782 9.121582,14 9.0786133,14 C9.0284834,14 8.9828291,13.979411 8.9416504,13.938232 C8.9004717,13.897054 8.8798828,13.851399 8.8798828,13.80127 C8.8798828,13.785156 8.9053955,13.709065 8.9564209,13.572998 C9.0074463,13.43693 9.0839844,13.240885 9.1860352,12.984863 L10.002441,10.911621 L8.2514648,9.7890625 C8.0043945,9.6315107 7.8148398,9.5093184 7.6828003,9.4224854 C7.5507612,9.3356533 7.4762373,9.2841797 7.4592285,9.2680664 C7.4252114,9.2358398 7.4082031,9.189291 7.4082031,9.128418 C7.4082031,9.0496416 7.4310303,8.9905596 7.4766846,8.9511719 C7.5223389,8.9117832 7.5908203,8.8920898 7.6821289,8.8920898 C7.68929,8.8920898 7.7555337,8.8974609 7.8808594,8.9082031 C8.0061846,8.9189453 8.1905928,8.9350586 8.434082,8.956543 L10.598633,9.1391602 L11.087402,7.0605469 C11.150065,6.7902021 11.200867,6.5807295 11.239807,6.4321289 C11.278748,6.2835288 11.305827,6.1958008 11.321045,6.1689453 C11.35148,6.1152344 11.407877,6.0883789 11.490234,6.0883789 z" >
</Path>
</StackPanel>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Para utilizar basta:
<local:FiveStarRating HorizontalAlignment="Left" Height="12"
Background="Black" FrontStarBackground="DarkOrange" Maximum="10"
Value="{Binding Path=RatingImdb}"/>
Aproveito para vos deixar um screen de algo que estou a desenvolver onde ja aplico este controlo

InertiaScrollViewer – ScrollViewer com inercia!
Fevereiro 26, 2009Com este ScrollViewer temos a capacidade de fazer scroll apenas com o arrastar do rato
Updated
public class InertiaScrollViewer : ScrollViewer
{
DispatcherTimer _yourTimer;
public InertiaScrollViewer()
{
_yourTimer = new DispatcherTimer();
_yourTimer.Interval = new TimeSpan(0, 0, 0, 0, 2);
_yourTimer.Tick += new EventHandler(yourTimer_Tick);
_yourTimer.Start();
this.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
this.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
}
#region Overrides
protected override void OnPreviewMouseDown(System.Windows.Input.MouseButtonEventArgs e)
{
base.OnMouseDown(e);
InertiaScrollViewer.SetIsDragging(this, true);
InertiaScrollViewer.SetTargetX(this, e.GetPosition(this).X);
InertiaScrollViewer.SetTargetY(this, e.GetPosition(this).Y);
double offsetx = this.HorizontalOffset - e.GetPosition(this).X;
double offsety = this.VerticalOffset - e.GetPosition(this).Y;
InertiaScrollViewer.SetOffset(this, new Point(offsetx, offsety));
}
protected override void OnMouseUp(System.Windows.Input.MouseButtonEventArgs e)
{
base.OnMouseUp(e);
InertiaScrollViewer.SetTargetX(this, (e.GetPosition(this).X));
InertiaScrollViewer.SetTargetY(this, (e.GetPosition(this).Y));
InertiaScrollViewer.SetIsDragging(this, false);
}
protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)
{
base.OnMouseLeave(e);
InertiaScrollViewer.SetIsDragging(this, false);
}
protected override void OnPreviewMouseMove(System.Windows.Input.MouseEventArgs e)
{
base.OnMouseMove(e);
if ((InertiaScrollViewer.GetIsDragging(this) == true))
{
InertiaScrollViewer.SetTargetX(this, (e.GetPosition(this).X));
InertiaScrollViewer.SetTargetY(this, (e.GetPosition(this).Y));
}
}
#endregion
private void yourTimer_Tick(object sender, EventArgs e)
{
if (InertiaScrollViewer.GetIsDragging(this))
{
double oldX = this.HorizontalOffset;
double oldY = this.VerticalOffset;
this.ScrollToVerticalOffset(this.VerticalOffset + (((InertiaScrollViewer.GetTargetY(this) + InertiaScrollViewer.GetOffset(this).Y) - this.VerticalOffset) * .3));
this.ScrollToHorizontalOffset(this.HorizontalOffset + ((InertiaScrollViewer.GetTargetX(this) + InertiaScrollViewer.GetOffset(this).X) - this.HorizontalOffset) * .3);
InertiaScrollViewer.SetVelocityX(this, (this.HorizontalOffset + ((InertiaScrollViewer.GetTargetX(this) + InertiaScrollViewer.GetOffset(this).X) - this.HorizontalOffset) * .3) - oldX);
InertiaScrollViewer.SetVelocityY(this, (this.VerticalOffset + (((InertiaScrollViewer.GetTargetY(this) + InertiaScrollViewer.GetOffset(this).Y) - this.VerticalOffset) * .3)) - oldY);
}
else
{
if (Math.Abs(Math.Round(InertiaScrollViewer.GetVelocityX(this), 3)) != 0.000)
{
this.ScrollToHorizontalOffset(this.HorizontalOffset + InertiaScrollViewer.GetVelocityX(this));
this.ScrollToVerticalOffset(this.VerticalOffset + InertiaScrollViewer.GetVelocityY(this));
InertiaScrollViewer.SetVelocityX(this, InertiaScrollViewer.GetVelocityX(this) * VelocityConst);
InertiaScrollViewer.SetVelocityY(this, InertiaScrollViewer.GetVelocityY(this) * VelocityConst);
}
}
}
#region Properties
#region TargetX
public static double GetTargetX(DependencyObject obj)
{
return (double)obj.GetValue(TargetXProperty);
}
public static void SetTargetX(DependencyObject obj, double value)
{
obj.SetValue(TargetXProperty, value);
}
// Using a DependencyProperty as the backing store for TargetX. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TargetXProperty =
DependencyProperty.Register("TargetX", typeof(double), typeof(InertiaScrollViewer), new UIPropertyMetadata(0.0));
#endregion
#region TargetY
public static double GetTargetY(DependencyObject obj)
{
return (double)obj.GetValue(TargetYProperty);
}
public static void SetTargetY(DependencyObject obj, double value)
{
obj.SetValue(TargetYProperty, value);
}
// Using a DependencyProperty as the backing store for TargetY. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TargetYProperty =
DependencyProperty.Register("TargetY", typeof(double), typeof(InertiaScrollViewer), new UIPropertyMetadata(0.0));
#endregion
#region Offset
public static Point GetOffset(DependencyObject obj)
{
return (Point)obj.GetValue(OffsetProperty);
}
public static void SetOffset(DependencyObject obj, Point value)
{
obj.SetValue(OffsetProperty, value);
}
// Using a DependencyProperty as the backing store for Offset. This enables animation, styling, binding, etc...
public static readonly DependencyProperty OffsetProperty =
DependencyProperty.Register("Offset", typeof(Point), typeof(InertiaScrollViewer), new UIPropertyMetadata(new Point(0, 0)));
#endregion
#region Velocity
public static double GetVelocityX(DependencyObject obj)
{
return (double)obj.GetValue(VelocityXProperty);
}
public static void SetVelocityX(DependencyObject obj, double value)
{
obj.SetValue(VelocityXProperty, value);
}
// Using a DependencyProperty as the backing store for VelocityX. This enables animation, styling, binding, etc...
public static readonly DependencyProperty VelocityXProperty =
DependencyProperty.RegisterAttached("VelocityX", typeof(double), typeof(InertiaScrollViewer), new UIPropertyMetadata(0.0));
public static double GetVelocityY(DependencyObject obj)
{
return (double)obj.GetValue(VelocityYProperty);
}
public static void SetVelocityY(DependencyObject obj, double value)
{
obj.SetValue(VelocityYProperty, value);
}
// Using a DependencyProperty as the backing store for VelocityY. This enables animation, styling, binding, etc...
public static readonly DependencyProperty VelocityYProperty =
DependencyProperty.Register("VelocityY", typeof(double), typeof(InertiaScrollViewer), new UIPropertyMetadata(0.0));
public double VelocityConst
{
get { return (double)GetValue(VelocityConstProperty); }
set { SetValue(VelocityConstProperty, value); }
}
// Using a DependencyProperty as the backing store for VelocityConst. This enables animation, styling, binding, etc...
public static readonly DependencyProperty VelocityConstProperty =
DependencyProperty.Register("VelocityConst", typeof(double), typeof(InertiaScrollViewer), new UIPropertyMetadata(0.96));
#endregion
#region IsDragging
public static bool GetIsDragging(DependencyObject obj)
{
return (bool)obj.GetValue(IsDraggingProperty);
}
public static void SetIsDragging(DependencyObject obj, bool value)
{
obj.SetValue(IsDraggingProperty, value);
}
// Using a DependencyProperty as the backing store for IsDragging. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsDraggingProperty =
DependencyProperty.Register("IsDragging", typeof(bool), typeof(InertiaScrollViewer), new UIPropertyMetadata(false));
#endregion
#endregion
}
Para usar basta definir no Template que queremos usar o nosso InertiaScrollViewer
<ItemsControl>
<ItemsControl.Template>
<ControlTemplate>
<local:InertiaScrollViewer>
<StackPanel IsItemsHost="True"/>
</local:InertiaScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
Em breve vou colocar um Canvas exactamente com o mesmo funcionamento, mas para os UiElements que estão dentro dele…
Até breve,
Miguel Duarte

De volta. E desta vez mais activo
Fevereiro 19, 2009Bem acho que vou voltar a escrever no meu blog para ajudar e poder ser ajudado sobre algumas questões sobre WPF.
Espero desta vez também ter tempo para abordar um pouco mais a tecnologia, WCF e WF.
Bem… então até breve

Tranformar Array Bytes em BitmapImage
Março 26, 2007Deixo-vos aqui uma pequena função que nos permite transformar um Byte[] em BitmapImage, bastante útil quando guardamos imagens em base de dados ou transferindo por webServices!!
/// <summary>
/// Obter uma imagem atravez de um array de bytes
/// </summary>
/// <param name=”arraybytes”>array de bytes</param>
/// <returns>devolve um BitmapImage que podemos adicionar á source </returns>
/// <example>Obj.source=getImage(byte[])</example>
BitmapImage getImage(byte[] arraybytes)
{
// Criar a Imagem
// NOTE: Isto n é um Bitmap normal (GDI+)
BitmapImage bitmap = new BitmapImage();
if (arraybytes != null)
{
MemoryStream strm = new MemoryStream(arraybytes);
bitmap.BeginInit();
bitmap.StreamSource = strm;
bitmap.EndInit();
}
//COMMENT: Retorna a Imagem
return bitmap;
}

Blend Release Candidate
Março 16, 2007Já está diponível para download a nova RC do Microsoft Blend que pode ser descarregada em:
http://www.microsoft.com/products/expression/en/expression-blend/try.mspx
Aproveito também para deixar uns vídeos a todos aqueles que tal como eu se pretendem iniciar em WPF com umas brincadeiras engraçadas.
Real-world WPF: Introduction to Blend (Part1)
Real-world WPF: Introduction to Blend (Part2)

TECH DAYS – 2007 – A minha Agenda!
Março 16, 2007O Tech Days é já para a semana e então já estive a fazer a minha agenda!
Vou ter que me dividir em 2 por algumas vezes…
As minhas Sessões

O que fazer com um projecto Antigo??
Março 12, 2007Aqui vamos meu primeiro Post, e vou começar por uma questão que fiz a mim mesmo quando comecei a desenvolver em wpf num projecto “a sério”.
O que vou fazer com os módulos que já tenho, recomeçar tudo de novo??
A resposta a esta pergunta é simples… não… posso integrar XAML em Windows Forms e Windows Forms (Aqui quando me refiro a Windows Forms estou-me a referir controls/Usercontrols) em XAML.
Para isso basta usar o namespace System.Windows.Forms.Integration
Para integrar XAML em Windows Forms fazemos:
//Declarar/Construir o Host para colacar XAML dentro de uma Windows Form Framework 2.0
System.Windows.Forms.Integration.ElementHost HostdeXAML = new System.Windows.Forms.Integration.ElementHost();
//Declarar o UserControl de XAML
ClassXAML child = new ClassXAML();
HostdeXAML .Child=child;
HostdeXAML.Dock = DockStyle.Fill;
this.Controls.Add(HostdeXAML);
Para integrar Windows Forms em XAML fazemos:
System.Windows.Forms.Integration.WindowsFormsHost HostdeForms = new System.Windows.Forms.Integration.WindowsFormsHost();
ClassForms child = new ClassForms();
HostdeForms.Child=child;
HostdeForms.Margin=new System.Windows.Thickness(0);
HostdeForms.Child = child;
System.Windows.Controls.Grid.SetRow(HostdeForms, 0);
System.Windows.Controls.Grid.SetColumn(HostdeForms, 0);
myGrid.Children.Add(HostdeForms);

