Re: noesisGUI v1.2 BETA 6
Yes, you can create an image manually this way:
Code: Select all
Ptr<TextureSource> source = *new TextureSource("Themes/Images/icon_MDD_blue1.png");
Ptr<Image> image = *new Image();
image->SetSource(source.GetPtr());
- darthmaule2
- Posts: 98
- Joined:
Re: noesisGUI v1.2 BETA 6
Thanks, that works. But how do I bind to it? I've tried to expose a property in the code-behind and tried all of these types:
- TextureSource
- Image
- ImageSource
The problem is when I try to bind to that property from the xaml...
<Image HorizontalAlignment="Left" Width="32" Height="32" Margin="4,0,0,0" Source="{Binding ItemImage}"/>
I get this runtime error:
Can't create ComponentConverter<ImageSource>, it is not registered
- TextureSource
- Image
- ImageSource
The problem is when I try to bind to that property from the xaml...
<Image HorizontalAlignment="Left" Width="32" Height="32" Margin="4,0,0,0" Source="{Binding ItemImage}"/>
I get this runtime error:
Can't create ComponentConverter<ImageSource>, it is not registered
Re: noesisGUI v1.2 BETA 6
It seems that in the reorganization of classes we are doing in v1.2 we did something wrong and several components are missing.
Let us investigate it and fix it. We are going to release a new beta this week.
Thanks!
Let us investigate it and fix it. We are going to release a new beta this week.
Thanks!
Re: noesisGUI v1.2 BETA 6
And yes, binding the TextureSource or its base class ImageSource is the correct way.
-
sfernandez
Site Admin
- Posts: 3093
- Joined:
Re: noesisGUI v1.2 BETA 6
I created the following sample that shows how to bind an ImageSource (or TextureSource) property to an Image element:Thanks, that works. But how do I bind to it? I've tried to expose a property in the code-behind and tried all of these types:
- TextureSource
- Image
- ImageSource
The problem is when I try to bind to that property from the xaml...
<Image HorizontalAlignment="Left" Width="32" Height="32" Margin="4,0,0,0" Source="{Binding ItemImage}"/>
I get this runtime error:
Can't create ComponentConverter<ImageSource>, it is not registered
Code: Select all
//////////////////////////////////////////////////
class ViewModel : public BaseComponent, public INotifyPropertyChanged
{
public:
ViewModel() { }
~ViewModel() { mDestroyed(this); }
ImageSource* GetImage() const { return mImage.GetPtr(); }
void SetImage(ImageSource* image) { mImage.Reset(image); }
PropertyChangedEventHandler& PropertyChanged() { return mPropertyChanged; }
DestroyedEventHandler& Destroyed() { return mDestroyed; }
private:
Ptr<ImageSource> mImage;
PropertyChangedEventHandler mPropertyChanged;
DestroyedEventHandler mDestroyed;
NS_IMPLEMENT_INLINE_REFLECTION(ViewModel, BaseComponent)
{
NsMeta<TypeId>("ViewModel");
NsImpl<INotifyPropertyChanged>();
NsProp("Image", &ViewModel::mImage);
}
};
//////////////////////////////////////////////////
class TestControl : public UserControl
{
public:
TestControl() { }
void OnPostInit()
{
Ptr<ViewModel> vm = *new ViewModel();
Ptr<Render::ITexture2D> tex = NsDynamicCast< Ptr<Render::ITexture2D> >(
NsGetSystem<Resource::IResourceSystem>()->Load("Data/XamlPlayer/test.jpg"));
Ptr<TextureSource> img = *new TextureSource(tex.GetPtr());
vm->SetImage(img.GetPtr());
SetDataContext(vm.GetPtr());
}
NS_IMPLEMENT_INLINE_REFLECTION(TestControl, UserControl)
{
NsMeta<TypeId>("TestControl");
}
};
Code: Select all
<UserControl x:Class="TestControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Image Source="{Binding Image}" Width="200" Height="100" Stretch="Fill"/>
</UserControl>
Code: Select all
//...
ImageSource* GetImage() const { return mImage.GetPtr(); }
void SetImage(ImageSource* image) { mImage.Reset(image); }
// ...
Ptr<ImageSource> mImage;
NS_IMPLEMENT_INLINE_REFLECTION(ViewModel, BaseComponent)
{
// This works now
NsProp("Image", &ViewModel::mImage);
// This does not work now (we will fix it in the next release)
//NsProp("Image", &ViewModel::GetImage, &ViewModel::SetImage);
}
Re: noesisGUI v1.2 BETA 7
Beta7 available for downloading! Many improvements and bug fixes, the changelog is so big that we didn't find time to organize it. Will be updated in the next beta, before the final release.
Re: noesisGUI v1.2 BETA 6
This was fixed in b7.There is only a restriction now (we are going to fix in the next release), the exposed property must be a Ptr type, you cannot use a Getter/Setter returning a pointer to the ImageSource:
Re: noesisGUI v1.2 BETA 7
I get the following runtime error when I run
requires version 1.2.0 or later, but Noesis.dylib provides version 1.0.0
requires version 1.2.0 or later, but Noesis.dylib provides version 1.0.0
Re: noesisGUI v1.2 BETA 7
This is probably because an older version of NoesisGUI is being loaded. The latest beta is versioned this way:I get the following runtime error when I run
requires version 1.2.0 or later, but Noesis.dylib provides version 1.0.0
Code: Select all
otool -L Noesis.dylib
Noesis.dylib:
@rpath/Noesis.dylib (compatibility version 1.2.0, current version 1.2.0)
Re: noesisGUI v1.2 BETA 7
i want download this, but say:
You are not authorised to download this attachment.
You are not authorised to download this attachment.
Who is online
Users browsing this forum: No registered users and 0 guests