Hello,
I have a problem that i cant solve :(
I have a user control (xaml file and cs file)
in xaml it's like:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Demo.CtrlContent"
x:Name="UserControl"
d:DesignWidth="598.333" d:DesignHeight="179.133" xmlns:Demo="clr-namespace:Demo" >
<UserControl.Resources>
<Storyboard x:Key="SBSmall">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(FrameworkElement.Width)">
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="I WANT TO BIND VALUE HERE"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<Border BorderBrush="#FFC2C0C1" CornerRadius="3,3,3,3" BorderThickness="1,1,1,1" RenderTransformOrigin="0.5,0.5" x:Name="border" Margin="1,3,1,3" HorizontalAlignment="Left" VerticalAlignment="Top" Width="300">
and .cs file:
public partial class CtrlContent {
private mindef W { get { return (mindef) Window.GetWindow(this); } }
public double MedWidth { // I WANT BIND THIS VALUE GO TO STORYBOARD VALUE IN XAML ABOVE
get {
double actualW;
if(W == null) actualW = SystemParameters.PrimaryScreenWidth;
else actualW = W.WrapMain.ActualWidth;
return actualW - border.Margin.Left - border.Margin.Right;
}
}
public double SmlWidth { get { return MedWidth / 2; } }
public CtrlContent () { this.InitializeComponent(); }
public CtrlContent (Content content) {
this.InitializeComponent();
Document = content;
}
}
in my .cs file there's a property called MedWidth, and in XAML file there's a storyboard called: SBSmall
I want to bind my storyboard value to my property in class ctrlcontent.
*the idea is, the storyboard is an animation to resize the control to a certain width depends on its parent container (the width is dynamic)
anybody? please :)
thanks!