|
Patterns are for programmers....the compiler doesn't know anything about MVVM.
If there's a class called DataGridVisibilityConverter in a namespace CNRPGlobal.Converters in an assembly GlobalLibraryDefinitions then it should work.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Try a USerControl from scratch, totally stripped down..does this compile??
<UserControl x:Class="SilverlightTester.ConverterTestPage"
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"
xmlns:gspace="clr-namespace:CNRPGlobal.Converters;assembly=GlobalLibraryDefinitions"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
<gspace:DataGridVisibilityConverter x:Key="VisibilityConverter" />
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
</Grid>
</UserControl>
Mark Salsbery
Microsoft MVP - Visual C++
modified on Friday, May 20, 2011 2:25 PM
|
|
|
|
|
got past the compile issue. It was the space just before assembly:!!!
Now I just have to figure out my runtime issues with the resource dictionary.
It doesn't like having that resource along with a ResourceDictionary entry! WTF???
|
|
|
|
|
Hmm CodeProject editor must have added the space - there's no space in my code here!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
WOOHOO!!!
Got a clean compile AND a good XAML parse. Here is the final results I had to implement!
xmlns:g="clr-namespace:CNRPGlobal.Converters;assembly=GlobalLibraryDefinitions"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/GlobalLibraryDefinitions;component/Themes/Generic.xaml" />
<ResourceDictionary>
<g:DataGridVisibilityConverter x:Key="VisibilityConverter" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
|
|
|
|
|
Awesome! Was just about to send this...
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/GlobalLibraryDefinitions;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters:IndexGreaterThanZeroToVisibilityConverter x:Key="IndexGreaterThanZeroToVisibilityConverter" />
</ResourceDictionary>
</UserControl.Resources>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It appears that the Storyboard won't accept a new RepeatBehavior structure once the animation has already begun.
I want to have an animation repeat endlessly, until the user clicks the window.
I have the animation RepeatBehavior set to Forever in the XAML. How do I stop the animation once it's begun?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
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.
|
|
|
|