-
- lomoonmoonbird
- Posts: 30
- Joined:
Code-behind not work
Hi
I have a UserControl in the that are MyControl1.xaml and MyControl1.xaml.cs
MyControl1.xaml:
MyControl1.xaml.cs
and error
is useless,whether or not i remove this , it has no impact,it is the x:class attribute on the root does the work,which is
am i missing something? thanks
I have a UserControl in the that are MyControl1.xaml and MyControl1.xaml.cs
MyControl1.xaml:
Code: Select all
<UserControl x:Class="putaogame.usercontrols.MyControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:putaogame.usercontrols"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0" Margin="10">
<StackPanel Orientation="Vertical">
<StackPanel>
<Button Content="lbutton1" Name="lbutton1" [color=#FF0000]KeyDown="lbutton1_KeyDown"[/color]></Button>
<Button Content="lbutton1" Name="lbutton2"></Button>
<Button Content="lbutton1" Name="lbutton3"></Button>
<Button Content="lbutton1" Name="lbutton4"></Button>
<Button Content="lbutton1" Name="lbutton5"></Button>
<Button Content="lbutton1" Name="lbutton6"></Button>
<Button Content="lbutton1" Name="lbutton7"></Button>
<Button Content="lbutton1" Name="lbutton8"></Button>
<Button Content="lbutton1" Name="lbutton9"></Button>
</StackPanel>
</StackPanel>
</Border>
<Border Grid.Row="0" Grid.Column="1" Margin="10">
<StackPanel Orientation="Vertical">
<StackPanel>
<Button Content="mbutton1" Name="mbutton1"></Button>
<Button Content="mbutton1" Name="mbutton2"></Button>
<Button Content="mbutton1" Name="mbutton3"></Button>
<Button Content="mbutton1" Name="mbutton4"></Button>
<Button Content="mbutton1" Name="mbutton5"></Button>
<Button Content="mbutton1" Name="mbutton6"></Button>
<Button Content="mbutton1" Name="mbutton7"></Button>
<Button Content="mbutton1" Name="mbutton8"></Button>
<Button Content="mbutton1" Name="mbutton9"></Button>
</StackPanel>
</StackPanel>
</Border>
<Border Grid.Row="0" Grid.Column="2" Margin="10">
<StackPanel Orientation="Vertical">
<StackPanel>
<Button Content="rbutton1" Name="rbutton1"></Button>
<Button Content="rbutton2" Name="rbutton2"></Button>
<Button Content="rbutton3" Name="rbutton3"></Button>
<Button Content="rbutton4" Name="rbutton4"></Button>
<Button Content="rbutton5" Name="rbutton5"></Button>
<Button Content="rbutton6" Name="rbutton6"></Button>
<Button Content="rbutton7" Name="rbutton7"></Button>
<Button Content="rbutton8" Name="rbutton8"></Button>
<Button Content="rbutton9" Name="rbutton9"></Button>
</StackPanel>
</StackPanel>
</Border>
</Grid>
</UserControl>
Code: Select all
#if UNITY_5
#define NOESIS
#endif
#if NOESIS
using Noesis;
using UnityEngine;
using System;
using System.Collections;
using System.Windows.Input;
#else
using System;
using System.Collections;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Controls.Primitives;
#endif
namespace putaogame.usercontrols
{
#if NOESIS
[UserControlSource("MyControl1.xaml")]
#endif
public class TestControl : UserControl
{
//...
}
public partial class MyControl1 : UserControl
{
public MyControl1()
{
InitializeComponent();
Debug.Log("this is initialize");
}
[color=#FF0040] private void lbutton1_KeyDown(object sender, KeyEventArgs e)
{
Debug.Log("sender" + sender);
}[/color]
}
}
it seems that this syntax
NoesisException: Loading Assets/putaogame/usercontrol/MyControl1.xaml
CodeBehind method 'lbutton1_KeyDown' not found
Noesis.Error.Check () (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisError.cs:26)
NoesisGUISystem.Noesis_LoadXAML (System.String xamlFile) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisGUISystem.cs:406)
NoesisGUISystem.Load (System.String xamlFile) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisGUISystem.cs:279)
NoesisGUISystem.LoadXaml (System.String xamlFile) (at Assets/Plugins/NoesisGUI/Scripts/Core/NoesisGUISystem.cs:47)
NoesisGUIPanel.LoadXaml () (at Assets/Plugins/NoesisGUI/Scripts/NoesisGUIPanel.cs:495)
NoesisGUIPanel.OnEnable () (at Assets/Plugins/NoesisGUI/Scripts/NoesisGUIPanel.cs:383)
Code: Select all
#if NOESIS
[UserControlSource("MyControl1.xaml")]
#endif
Code: Select all
x:Class="putaogame.usercontrols.MyControl1"
Re: Code-behind not work
Code: Select all
<Button Content="lbutton1" Name="lbutton1" KeyDown="lbutton1_KeyDown"></Button>
Thanks!
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 6 guests