|
Hey Mark!
You're okay for a C++ guy.
So I implemented my convert. check
Then I implemented the binding. check
Added the namespace for local. check
Then did local: my converter was visible and got it set with a key. check
Ran the solution and got this error at compile time.
Error 1 The tag 'DataGridVisibilityConverter' does not exist in XML namespace 'clr-namespace:CNRPGlobal.Converters; assembly=GlobalLibraryDefinitions'.
So how is it I can type local: and see my class library. Yet when I compile XAML cannot? I confirmed it is public.
Here is a snippet of what I've got:
xmlns:local="clr-namespace:CNRPGlobal.Converters; assembly=GlobalLibraryDefinitions"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<UserControl.Resources>
<ResourceDictionary x:Key="styles" Source="/GlobalLibraryDefinitions;component/Themes/Generic.xaml" />
<local:DataGridVisibilityConverter x:Key="VisibilityConverter" />
</UserControl.Resources>
And the consumption of the converter:
<cnrp:FormSection x:Name="designSection" Title="Design Section" DataContext="{Binding CurrentDesign, Mode=TwoWay}"
Visibility="{Binding ElementName=dgDesigns, Path=SelectedIndex, Mode=OneWay, Converter={StaticResource VisibilityConverter}}">
|
|
|
|
|
From what you've shown I can' see the problem.
Try a rebuild?
The namespace and assembly are correct and you have a reference to that assembly?
Also, "local" maybe not a good name for a namespace in a separate assembly
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
OMG -- the initial problem was I had a space between the namespace and the assembly name
But now I'm getting a runtime error
Local values are not allowed in resource dictionary with Source set [Line: 14 Position: 46]
It is pointing at my styles object!
modified on Friday, May 20, 2011 2:15 PM
|
|
|
|
|
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.
|
|
|
|