![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | type not defined when wiring events in xaml hello i am getting error "type VisualAMS.Welcome is not defined", when building, this error only occurs when i enter a name for the class either through blend or via the xaml otherwise it builds fine but i cannot wire events via controls created in expression blend. Using vb.net 2005 with the relevant ..Net 3.0 sdk etc, Expression Blend 1. This project was created from scratch based on the Family.Show app. Have tried everything, remove the name of the control and it builds fine, add it back in and the error returns, don't understand why... Enclose the following code, can pm on westy@xxxxxx and i can provide a zip with the project files otherwise general files are below thanks in advance Window1.xaml <Window 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/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:VisualAMS="clr-namespace:VisualAMS" x:Class="VisualAMS.Window1" Title="VisualAMS" Height="728" Width="960" Background="{DynamicResource MainBackgroundBrush}" ResizeMode="CanResizeWithGrip"> <DockPanel LastChildFill="False" Background="{DynamicResource MainBackgroundBrush}"> <Border x:Name="HeaderBorder" Width="Auto" Height="50" DockPanel.Dock="Top" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,0,0,1" Padding="10,0,10,0"> <DockPanel x:Name="Header" Width="Auto" Height="Auto"> <TextBlock xml:space="preserve" TextWrapping="Wrap" Margin="0,0,0,5" Width="Auto" Height="Auto" FontFamily="Arial" FontSize="24" FontWeight="Light" Foreground="{DynamicResource HeaderFontColor}"><Run Foreground="#FFCFD3DA">Visual</Run> <Run xml:space="preserve" FontWeight="Normal" FontStyle="Italic">AMS</Run></TextBlock> <DockPanel x:Name="CustomTextandLogo" DockPanel.Dock="Right" ScrollViewer.VerticalScrollBarVisibility="Disabled"> <Image ClipToBounds="True" HorizontalAlignment="Right" Margin="5,5,5,5" x:Name="CustomImage" Width="Auto" Height="40" DockPanel.Dock="Right" Grid.IsSharedSizeScope="False" ScrollViewer.VerticalScrollBarVisibility="Disabled"/> <TextBlock ClipToBounds="True" Margin="5,5,5,5" x:Name="CustomText" Width="Auto" Height="40" DockPanel.Dock="Right" FontFamily="Arial" FontSize="20" FontWeight="Light" Foreground="{DynamicResource HeaderFontColor}" Text="Your Name Here" TextAlignment="Right" TextWrapping="Wrap" Grid.IsSharedSizeScope="False" ScrollViewer.VerticalScrollBarVisibility="Disabled"/> </DockPanel> </DockPanel> </Border> <Border Margin="0,5,0,5" x:Name="MenuBorder" VerticalAlignment="Top" Width="Auto" DockPanel.Dock="Top"> <Menu SnapsToDevicePixels="True" Margin="5,0,0,0" VerticalAlignment="Bottom" Style="{DynamicResource MenuStyle}"> <MenuItem x:Name="FileMenu" InputGestureText="Ctrl+F" Header="_File" Style="{DynamicResource MenuItemStyle}"> <MenuItem x:Name="New" Command="{x:Null}" InputGestureText="Ctrl+N" Header="_New" Style="{DynamicResource MenuItemStyle}"/> <MenuItem x:Name="Open" Command="{x:Null}" InputGestureText="Ctrl+O" Header="_Open" Style="{DynamicResource MenuItemStyle}"/> <MenuItem x:Name="Save" Command="{x:Null}" InputGestureText="Ctrl+S" Header="_Save" Style="{DynamicResource MenuItemStyle}"/> <MenuItem x:Name="Exit" InputGestureText="Ctrl+Q" Header="_Exit" Style="{DynamicResource MenuItemStyle}"/> </MenuItem> <MenuItem x:Name="OptionsMenu" InputGestureText="Ctrl+T" Header="_Options" Style="{DynamicResource MenuItemStyle}"> <MenuItem x:Name="ProgramSettings" InputGestureText="Ctrl+P" Header="_Program Settings" Style="{DynamicResource MenuItemStyle}"/> <MenuItem x:Name="PersonalSettings" InputGestureText="Ctrl+L" Header="Persona_l Settings" Style="{DynamicResource MenuItemStyle}"/> <MenuItem x:Name="Admin" InputGestureText="Ctrl+A" Header="_Admin" Style="{DynamicResource MenuItemStyle}"/> </MenuItem> <MenuItem x:Name="HelpMenu" InputGestureText="Ctrl+H" Header="_Help" Style="{DynamicResource MenuItemStyle}"> <MenuItem x:Name="Contents" Header="_Contents" Style="{DynamicResource MenuItemStyle}"/> <MenuItem x:Name="Tips" Header="_Tips" Style="{DynamicResource MenuItemStyle}"/> <MenuItem x:Name="About" Header="_About" Style="{DynamicResource MenuItemStyle}"/> </MenuItem> </Menu> </Border> <Grid x:Name="MainGrid" Width="Auto" DockPanel.Dock="Top" Grid.IsSharedSizeScope="True"> <Grid HorizontalAlignment="Left" Margin="10,0,10,10" x:Name="DiagramPane" VerticalAlignment="Top" Width="Auto" Height="Auto"> <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Background="{DynamicResource DiagramGradientBrush}" BorderBrush="#FF747474" BorderThickness="1,1,1,1" CornerRadius="10,10,10,10"/> </Grid> <VisualAMS:Welcome VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="WelcomeUserControl" NewFileButtonClick="WelcomeUserControl_NewFileButtonClick" OpenFileButtonClick="WelcomeUserControl_OpenFileButtonClick" OpenRecentFileButtonClick="WelcomeUserControl_OpenRecentFileButtonClick"/> </Grid> </DockPanel> </Window> Welcome.xaml <UserControl 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/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="Welcome" Quote: > <DataTemplate x:Key="RecentFilesDataTemplate"> <Button Content="{TemplateBinding ContentPresenter.Content}"/> </DataTemplate> <Style x:Key="WelcomeButtonStyle" TargetType="{x:Type Button}"> <Setter Property="Foreground" Value="#FFFFFF" /> <Setter Property="Width" Value="Auto"/> <Setter Property="FontSize" Value="16"/> <Setter Property="FontFamily" Value="Calibri"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border x:Name="bd" CornerRadius="3,3,3,3" Padding="5,0,0,0"> <ContentPresenter SnapsToDevicePixels="True" VerticalAlignment="Stretch" RecognizesAccessKey="True" Margin="5,1,0,1"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsKeyboardFocused" Value="true"/> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Cursor" Value="Hand"/> <Setter Property="Background" TargetName="bd" Value="#FF29367B"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="RecentFileButtonStyle" TargetType="{x:Type Button}"> <Setter Property="Foreground" Value="#FFFFFF" /> <Setter Property="Width" Value="Auto"/> <Setter Property="FontSize" Value="16"/> <Setter Property="FontFamily" Value="Calibri"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border x:Name="bd" CornerRadius="3,3,3,3" Padding="20,0,0,0"> <ContentPresenter SnapsToDevicePixels="True" VerticalAlignment="Stretch" RecognizesAccessKey="True" Margin="5,1,0,1"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsKeyboardFocused" Value="true"/> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Cursor" Value="Hand"/> <Setter Property="Background" TargetName="bd" Value="#FF29367B"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources> <StackPanel> <!-- Header --> <Border Width="300" Padding="5,0,5,0" Opacity="0.8" x:Name="Header" Background="{DynamicResource WelcomeBackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1,1,1,0" CornerRadius="5,5,0,0" HorizontalAlignment="Center" > <Grid> <Rectangle Fill="{DynamicResource WelcomeHeaderBg}" Height="69"/> <TextBlock Padding="4,0,0,0" Text="Welcome" TextWrapping="Wrap" Foreground="{DynamicResource WelcomeHeaderFontColor}" FontSize="18" FontWeight="Bold" x:Name="HeaderTextBlock" HorizontalAlignment="Left" Margin="3.5,0,0,2" VerticalAlignment="Bottom"/> </Grid> </Border> <!-- Content --> <Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1,1,1,1"> <Grid Margin="0,0,0,0" x:Name="ContentGrid" Background="{DynamicResource InputBackgroundBrush}"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <StackPanel HorizontalAlignment="Stretch" Margin="5,20,5,10"> <Button Margin="0,0,0,5" x:Name="NewButton" Content="New" Click="NewButton_Click" IsDefault="True" HorizontalAlignment="Stretch" Style="{DynamicResource WelcomeButtonStyle}" Width="Auto"/> <Button Margin="0,0,0,5" x:Name="OpenButton" Content="Open..." Click="OpenButton_Click" HorizontalAlignment="Stretch" Style="{DynamicResource WelcomeButtonStyle}" Width="Auto"/> </StackPanel> <GridSplitter IsEnabled="False" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="1" Background="#FF3D4976" Margin="2,0,2,0"/> <Label Content="Open Recent" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1" Margin="10,0,0,0" Foreground="#FFB5C8D8"/> <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" x:Name="RecentFilesStackPanel" Margin="5,30.87,5,10"/> </Grid> </Border> <!-- Footer --> <Border Background="{DynamicResource BackgroundBrush}" Height="35" x:Name="Footer" Opacity="0.8" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1,0,1,1" CornerRadius="0,0,5,5"> <Label x:Name="VersionLabel" Margin="10,0,0,0" Foreground="#FFB5C8D8" Content="Version "/> </Border> </StackPanel> </UserControl> Welcome.vb ' Interaction logic for Welcome.xaml ' Control that will display initial welcome screen Imports System Imports System.Windows Imports System.Windows.Controls Imports System.Globalization Partial Public Class Welcome Inherits System.Windows.Controls.UserControl #Region "Constructors" Public Sub New() InitializeComponent() ' Construct inital methods CreateRecentFiles() DisplayVersion() End Sub #End Region #Region "Private Methods" ' Return list of recently used files (MRU) Private Sub CreateRecentFiles() For Each File As String In App.MRUList Dim FileButton As New Button FileButton.Content = System.IO.Path.GetFileName(File) FileButton.CommandParameter = File FileButton.Style = CType(FindResource("RecentFileButtonStyle"), Style) AddHandler FileButton.Click, New RoutedEventHandler(AddressOf OpenRecentFile_Click) ' Add button to stack panel RecentFilesStackPanel.Children.Add(FileButton) Next End Sub ' Return version of currently used assembly Private Sub DisplayVersion() Dim version As Version = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version VersionLabel.Content = VersionLabel.Content.ToString & " " & String.Format(CultureInfo.CurrentCulture, _ "{0}.{1}.{2}", version.Major, version.Minor, version.Build) End Sub #End Region #Region "Routed Events" Public Shared ReadOnly OpenRecentFileButtonClickEvent As RoutedEvent = EventManager.RegisterRoutedEvent("OpenRecentFileButtonClick", _ RoutingStrategy.Bubble, GetType(RoutedEventHandler), GetType(Welcome)) Public Shared ReadOnly NewFileButtonClickEvent As RoutedEvent = EventManager.RegisterRoutedEvent("NewFileButtonClick", _ RoutingStrategy.Bubble, GetType(RoutedEventHandler), GetType(Welcome)) Public Shared ReadOnly OpenFileButtonClickEvent As RoutedEvent = EventManager.RegisterRoutedEvent("OpenFileButtonClick", _ RoutingStrategy.Bubble, GetType(RoutedEventHandler), GetType(Welcome)) ' Expose the event for this control's container Public Custom Event OpenRecentFileButtonClick As RoutedEventHandler AddHandler(ByVal value As RoutedEventHandler) Me.AddHandler(Welcome.OpenRecentFileButtonClickEvent, value) End AddHandler RemoveHandler(ByVal value As RoutedEventHandler) Me.RemoveHandler(Welcome.OpenRecentFileButtonClickEvent, value) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Me.RaiseEvent(e) End RaiseEvent End Event Public Custom Event NewFileButtonClick As RoutedEventHandler AddHandler(ByVal value As RoutedEventHandler) Me.AddHandler(Welcome.NewFileButtonClickEvent, value) End AddHandler RemoveHandler(ByVal value As RoutedEventHandler) Me.RemoveHandler(Welcome.NewFileButtonClickEvent, value) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Me.RaiseEvent(e) End RaiseEvent End Event Public Custom Event OpenFileButtonClick As RoutedEventHandler AddHandler(ByVal value As RoutedEventHandler) Me.AddHandler(Welcome.OpenRecentFileButtonClickEvent, value) End AddHandler RemoveHandler(ByVal value As RoutedEventHandler) Me.RemoveHandler(Welcome.OpenRecentFileButtonClickEvent, value) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Me.RaiseEvent(e) End RaiseEvent End Event #End Region #Region "Event Handlers" Private Sub OpenRecentFile_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) [RaiseEvent](New RoutedEventArgs(OpenRecentFileButtonClickEvent, sender)) End Sub Private Sub NewButton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) [RaiseEvent](New RoutedEventArgs(NewFileButtonClickEvent, sender)) End Sub Private Sub OpenButton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) [RaiseEvent](New RoutedEventArgs(OpenFileButtonClickEvent, sender)) End Sub #End Region End Class Welcome.vb Imports System Imports System.IO Imports System.Net Imports System.Windows Imports System.Windows.Controls Imports System.Windows.Data Imports System.Windows.Media Imports System.Windows.Media.Animation Imports System.Windows.Navigation Namespace VisualAMS Partial Public Class Window1 Public Sub New() InitializeComponent() ' Insert code required on object creation below this point. End Sub Private Sub WelcomeUserControl_NewFileButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) End Sub Private Sub WelcomeUserControl_OpenFileButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) End Sub Private Sub WelcomeUserControl_OpenRecentFileButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) End Sub End Class End Namespace |
My System Specs![]() |
| | #2 (permalink) |
| XP Pro | Re: type not defined when wiring events in xaml I appear to have the same problem. However it works when written in C#. I am converting the OutlookUI HOL tutorial to VB.Net and have run into this problem of code not compiling when x:Name="foo" added to UserControl that has triggers. Has anyone found a solution? Regards, Jim Fitzwater |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Graphics card wiring | Graphic cards | |||
| Is it possible to include XAML files into another XAML file? | .NET General | |||