- realesmedia
- Posts: 85
- Joined:
in Xaml, Behaviors are searched for in the namespace NoesisApp, but registered in an anonymous namespace
Code: Select all
class MouseWheelBehavior final: public NoesisApp::BehaviorT<Noesis::FrameworkElement>
{
public:
MouseWheelBehavior() = default;
~MouseWheelBehavior() = default;
protected:
Noesis::Ptr<Noesis::Freezable> CreateInstanceCore() const override;
void OnAttached() override;
void OnDetaching() override;
private:
void OnPreviewMouseWheel(BaseComponent* sender, const MouseWheelEventArgs& e);
private:
NS_DECLARE_REFLECTION(MouseWheelBehavior, NoesisApp::BehaviorT<Noesis::FrameworkElement>)
};
NS_IMPLEMENT_REFLECTION(MouseWheelBehavior)
{
NsMeta<TypeId>("MouseWheelBehavior");
}
Code: Select all
<DataTemplate x:Key="Template.MaterialGroup" DataType="{x:Type MaterialGroupComponent}">
<Grid>
<Rectangle Fill="{StaticResource MainAccentBrush}" Height="2" VerticalAlignment="Top" Margin="-4,-4,-4,0"></Rectangle>
<TreeView x:Name="tvNodes" ItemsSource="{Binding Childs, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Top"
ItemContainerStyle="{StaticResource MaterialTreeViewItemsStyle}" SnapsToDevicePixels="True"
Background="{StaticResource panelBgBrush}"
BorderThickness="0" BorderBrush="{StaticResource MainAccentBrush}" Margin="0,20,0,0"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<i:Interaction.Behaviors>
<ei:MouseWheelBehavior/>
</i:Interaction.Behaviors>
</TreeView>
</Grid>
</DataTemplate>
- mingingmingler
- Posts: 28
- Joined:
Re: in Xaml, Behaviors are searched for in the namespace NoesisApp, but registered in an anonymous namespace
It's looking for the reflection type id, not the class namespace.
Change
NsMeta<TypeId>("MouseWheelBehavior");
to
NsMeta<TypeId>("NoesisApp.MouseWheelBehavior");
Change
NsMeta<TypeId>("MouseWheelBehavior");
to
NsMeta<TypeId>("NoesisApp.MouseWheelBehavior");
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: in Xaml, Behaviors are searched for in the namespace NoesisApp, but registered in an anonymous namespace
In the xaml you have the following:
That prefix is usually defined as:
Our XAML parser maps that namespace to "NoesisApp" because we have all default interactivity classes defined in there.
You can have your own behaviors and actions defined in your own namespaces, for example:
Then you just need to specify that namespace in your XAML:
Code: Select all
<ei:MouseWheelBehavior/>
Code: Select all
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
You can have your own behaviors and actions defined in your own namespaces, for example:
Code: Select all
namespace RealEsMedia
{
class MouseWheelBehavior final: public NoesisApp::BehaviorT<Noesis::FrameworkElement> { ... };
NS_IMPLEMENT_REFLECTION(MouseWheelBehavior)
{
// This is the Namespace.ClassName used by the XAML parser
NsMeta<TypeId>("RealEsMedia.MouseWheelBehavior");
}
}
Code: Select all
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:rem="clr-namespace:RealEsMedia">
...
<i:Interaction.Behaviors>
<rem:MouseWheelBehavior/>
</i:Interaction.Behaviors>
...
</UserControl>
- realesmedia
- Posts: 85
- Joined:
Re: in Xaml, Behaviors are searched for in the namespace NoesisApp, but registered in an anonymous namespace
ok, thank
I thought that for Behaviors it is necessary to use the ei namespace
I thought that for Behaviors it is necessary to use the ei namespace
Who is online
Users browsing this forum: No registered users and 7 guests