Mauro Valvano
Mauro Valvano

Reputation: 933

Extending from a button

I'm trying to do a simple thing but without success.

I need to extend from a button and create a custom button with custom proprieties (nothing to do with styles or visual settings).

I have created a simple class in the namespace AppEdil.UI.

namespace AppEdil.UI
{
    class MainMenuButton : Button
    {
        public int MenuTabIndex { get; set; }

        public MainMenuButton() 
        {

        }
    }

}

Then in the window xaml i added the namespace:

xmlns:ui = "clr-namespace:EdilCaselle.UI"

And then i added the buttons:

 <!-- Clients -->
 <ui:MainMenuButton Style="{StaticResource mainMenuButtonStyle}" Width="70" Height="60" Margin="0, 0, 5, 0" HorizontalAlignment="Left" VerticalAlignment="Center">
     <ui:MainMenuButton.Content>
         <StackPanel>
             <Image Source="Images/Big_Icons/user.png" Height="32" Width="32"/>
             <TextBlock>Clienti</TextBlock>
         </StackPanel>
     </ui:MainMenuButton.Content>
 </ui:MainMenuButton>

But i get different errors:

Can you help me?

Upvotes: 1

Views: 83

Answers (1)

Steve
Steve

Reputation: 6444

You're missing the public keyword from your class. Add that and it will work! :)

Upvotes: 2

Related Questions