|
Change the RepeatBehavior and call Stop()
|
|
|
|
|
Thanks.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
A Stop() call on the StoryBoard should be sufficient. You don't need to do anything else.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Another alternative maybe...all in XAML...
<Grid Name="theGrid" Background="SteelBlue" >
<Grid.Triggers>
<EventTrigger RoutedEvent="Grid.Loaded">
<BeginStoryboard x:Name="gridBeginStoryboard" >
<Storyboard>
<DoubleAnimation Storyboard.TargetName="theGrid"
Storyboard.TargetProperty="Opacity"
From="1.0" To="0.0" Duration="0:0:2"
AutoReverse="True" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger SourceName="theGrid" RoutedEvent="Grid.MouseLeftButtonDown">
<StopStoryboard BeginStoryboardName="gridBeginStoryboard" />
</EventTrigger>
</Grid.Triggers>
</Grid>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
u can create a doubleanimation type, and then set douleanimation type equals(storyboard)Findresource("name of storyboard");
and doubleanimation.stop()..
|
|
|
|
|
Hi All,
I am running code from http://msdn.microsoft.com/en-us/library/gg197425(v=XNAGameStudio.35).aspx[^].
i am able to compile and run the code successfully but I am not able to see any 3D objects on screen.
My System details as follows.
System : Widnows XP with 2GB RAM
Visual Studio 2010 SP1
DirectX SDK 9.0
SilverLight 5.0 Beta
XNA Framework.
If someone passed from same that please help me.
Regards
Rushi
|
|
|
|
|
First thing, try to check if the link to the sample provided on the website runs on your machine.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
hello, I'm a WPF newbie
i have a class called Employee that has a single property Name, when i try to bind it to TextBlock, nothing happens...
what am i doing wrong ?
public MainWindow()
{
InitializeComponent();
Employee emp = new Employee("lolo");
grd.DataContext = emp;
}
<Window x:Class="WpfTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid Name="grd">
<TextBlock Text="{Binding Path=Name}" Name="textBlock1"></TextBlock>
</Grid>
</Window>
your help is very much appreciated
|
|
|
|
|
Could you please supply the code for your Employee class? There's no problem with your XAML or the MainWindow class.
|
|
|
|
|
class Employee
{
string _name;
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
public Employee()
{ }
public Employee(string strName)
{
this.Name = _name;
}
}
thank you Pete
|
|
|
|
|
Try this:
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnChanged(string property)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler == null) return;
handler(this, new PropertyChangedEventArgs(property));
}
}
public class Employee : ViewModelBase
{
string _name;
public string Name
{
get
{
return _name;
}
set
{
if (_name == value) return;
_name = value;
OnChanged("Name");
}
}
public Employee(string strName)
{
this.Name = strName;
}
} BTW - your problem was actually in the constructor. You had:
this.Name = _name Effectively you were assigning an empty value to Name because you were using the wrong variable; it should have been strName.
|
|
|
|
|
|
No problem, I'm glad to help.
|
|
|
|
|
Good catch!
The more anger towards the past you carry in your heart, the less capable you are of loving in the present.
My Blog![ ^]
|
|
|
|
|
You need to implement an interface called an INOtifyPropertyChanged interface[^]in your class.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Strictly speaking, in this case he doesn't because of the sequence of events he's using to hook things up. At the point he assigns Name, the class isn't bound to the DataContext so there's nothing for the PropertyChangedEventHandler to raise the notification to.
The problem was down to an incorrect variable assignment in his code. I've added some code to show him a ViewModelBase implementation so that he gets an understanding, and so that binding will work property for him.
|
|
|
|
|
Pete O'Hanlon wrote: Strictly speaking, in this case he doesn't because of the sequence of events he's using to hook things up. At the point he assigns Name, the class isn't bound to the DataContext so there's nothing for the PropertyChangedEventHandler to raise the notification to.
Point noted and understood.
However, this sort of code is not really going to solve any purpose, as when the property value changes, the UI is not going to be refreshed.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
modified on Wednesday, May 18, 2011 2:43 AM
|
|
|
|
|
Oh, I agree entirely. My first port of call is always a ViewModelBase class of some description.
|
|
|
|
|
I've encountered:
<Grid Name="GrdParams" >
<TextBlock Grid.Column="0" Grid.Row="0" Text="Frequency" VerticalAlignment="Center" />
<Slider Grid.Column="1" Grid.Row="0" Minimum="0" Maximum="0.25" SmallChange="0.001" Value="{Binding Mode=TwoWay, Path=Frequency}" ValueChanged="FreqSlider_ValueChanged" />
<TextBlock Name="TxtFreq" Grid.Column="2" Grid.Row="0" />
</Grid>
and
private void FreqSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (this.TxtFreq != null)
{
this.TxtFreq.Text = (sender as Slider).Value.ToString("###0.####");
}
} Which I found strange there was no "INotifyPropertyChanged" implementation or anything just the binding takes care of it.
Wolves smell fear slay and the coward, men smell gold and slay his brother.
|
|
|
|
|
Hello All,
I have this application that creates a DrawingGroup in a background thread.
How can I render this on a canvas of the main thread after the background thread is completed?
Any attempt results in an exception that the DrawingGroup belongs to different thread.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
modified on Monday, May 16, 2011 8:53 PM
|
|
|
|
|
Paul Selormey wrote: How can I render this on a canvas of the main thread after the background thread is completed?
Freeze it or create it on the UI thread...only two options I can think of...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the reply.
Trying to avoid creating it on the UI thread since it takes a lot of time.
I will try the freezing and see if it will work.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Hello Mark,
Thanks so much, freezing it works as expected.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Hi,
I'm just wondering how to modify DataTemplate programmatically? Here's my XAML code:
<ListView Grid.Row="2" Name="lstvTCKeyValue" Margin="10,33,10,0" ItemsSource="{Binding}" MouseDoubleClick="lstvTCKeyValue_MouseDoubleClick" KeyDown="lstvTCKeyValue_KeyDown" SelectionChanged="lstvTCKeyValue_SelectionChanged" GridViewColumnHeader.Click="lstvTCKeyValue_Click">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
<Setter Property="VerticalContentAlignment" Value="Stretch"></Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.Resources>
<DataTemplate x:Key="Column1">
<Border BorderThickness="0,0,1,0" BorderBrush="Gray" Margin="-6,0,-6,0">
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Path=test_config_key}">
<TextBlock.ToolTip>
<TextBlock Text="{Binding Path=test_config_key}"></TextBlock>
</TextBlock.ToolTip>
</TextBlock>
</Border>
</DataTemplate>
I'd like to modify border settings of data template named "Column1".
Thank you in advance.
Goran
|
|
|
|
|
You cannot modify DataTemplates in Silverlight.
The best you can do is keep alternate templates ready and assign them as required.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|