Click here to Skip to main content
13,088,305 members (39,817 online)

Silverlight / WPF

AnswerRe: Opening new WPF form in seperate thread. Pin
SledgeHammer012-Feb-13 10:28
memberSledgeHammer012-Feb-13 10:28 
GeneralRe: Opening new WPF form in seperate thread. Pin
Hema Bairavan3-Feb-13 2:57
memberHema Bairavan3-Feb-13 2:57 
GeneralRe: Opening new WPF form in seperate thread. Pin
SledgeHammer013-Feb-13 7:41
memberSledgeHammer013-Feb-13 7:41 
GeneralRe: Opening new WPF form in seperate thread. Pin
Jason Gleim1-Mar-13 8:00
memberJason Gleim1-Mar-13 8:00 
QuestionHow to user control view open in center of main parent window ? Pin
rahul ameta2-Feb-13 1:56
memberrahul ameta2-Feb-13 1:56 
Questionarrange elements inside wpf Pin
Remix Mixdox1-Feb-13 22:27
memberRemix Mixdox1-Feb-13 22:27 
AnswerRe: arrange elements inside wpf Pin
Abhinav S3-Feb-13 7:02
mvpAbhinav S3-Feb-13 7:02 
QuestionCustom Controls Pin
Sawyer19881-Feb-13 7:05
memberSawyer19881-Feb-13 7:05 
Hi! Began studying wpf. Versed with custom control'ami. I create the control (simple button) from Control.
The question is - is it possible to not draw method OnRend (such as they call it), and make the template, the file generic.xaml? And still do not understand why does not my click handler.Confused | :confused:
файл MyButton.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Globalization;
namespace My_Lib
    public class MyButton : Control
        public static readonly RoutedEvent MyClickEvent;  
        static MyButton()
            DefaultStyleKeyProperty.OverrideMetadata(typeof(MyButton), new FrameworkPropertyMetadata(typeof(MyButton)));
            MyClickEvent = EventManager.RegisterRoutedEvent("MyClick", RoutingStrategy.Bubble,
                typeof(RoutedEventHandler), typeof(MyButton));                       
        public event RoutedEventHandler MyClick
            add {
                base.AddHandler(MyButton.MyClickEvent, value);
            remove {
                base.RemoveHandler(MyButton.MyClickEvent, value);

файл generic.xaml
    <LinearGradientBrush x:Key="Gray" 
    StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="PaleTurquoise" Offset="0" />
        <GradientStop Color="#CCCCFF" Offset="0.5" />
        <GradientStop Color="Teal" Offset="1" />
    <LinearGradientBrush x:Key="Gray2" 
    StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="PaleGreen" Offset="0" />
        <GradientStop Color="#99CC99" Offset="0.5" />
        <GradientStop Color="Green" Offset="1" />
    <Style TargetType="{x:Type local:MyButton}">
        <Setter Property="Width" Value="100"></Setter>
        <Setter Property="Height" Value="40"></Setter>
        <Setter Property="Template">
                <ControlTemplate TargetType="{x:Type local:MyButton}">
                        Width="{TemplateBinding Width}"
                        Height="{TemplateBinding Height}"
                        Background="{StaticResource Gray}"                        
                        <ContentPresenter x:Name="ButtonContentPresenter"
                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                            Margin="{TemplateBinding Padding}" 
                        <Trigger Property="IsMouseOver"  Value="True">
                            <Setter  TargetName="ButtonBorder"
                                     Value="{StaticResource Gray2}">

файл MainWindow.xaml.cs
namespace MyComponentsTest
    public partial class MainWindow : Window
        public MainWindow()
        private void myButton1_MyClick(object sender, RoutedEventArgs e)

QuestionApplication Launcher Pin
Mycroft Holmes31-Jan-13 13:49
memberMycroft Holmes31-Jan-13 13:49 
AnswerRe: Application Launcher Pin
Abhinav S1-Feb-13 8:22
mvpAbhinav S1-Feb-13 8:22 
QuestionWPF controls refresh Pin
caradri31-Jan-13 1:50
membercaradri31-Jan-13 1:50 
AnswerRe: WPF controls refresh Pin
Pete O'Hanlon31-Jan-13 2:44
protectorPete O'Hanlon31-Jan-13 2:44 
GeneralRe: WPF controls refresh Pin
caradri31-Jan-13 10:20
membercaradri31-Jan-13 10:20 
GeneralRe: WPF controls refresh Pin
Richard Deeming31-Jan-13 11:25
memberRichard Deeming31-Jan-13 11:25 
GeneralRe: WPF controls refresh Pin
caradri2-Feb-13 17:59
membercaradri2-Feb-13 17:59 
GeneralRe: WPF controls refresh Pin
caradri3-Feb-13 20:16
membercaradri3-Feb-13 20:16 
QuestionRoutedEvent vs AttachedEvent Pin
devvvy29-Jan-13 22:30
memberdevvvy29-Jan-13 22:30 
AnswerRe: RoutedEvent vs AttachedEvent Pin
Pete O'Hanlon29-Jan-13 22:51
protectorPete O'Hanlon29-Jan-13 22:51 
GeneralRe: RoutedEvent vs AttachedEvent Pin
devvvy29-Jan-13 23:02
memberdevvvy29-Jan-13 23:02 
GeneralRe: RoutedEvent vs AttachedEvent Pin
Pete O'Hanlon30-Jan-13 0:45
protectorPete O'Hanlon30-Jan-13 0:45 
GeneralRe: RoutedEvent vs AttachedEvent Pin
devvvy30-Jan-13 2:40
memberdevvvy30-Jan-13 2:40 
GeneralRe: RoutedEvent vs AttachedEvent Pin
Pete O'Hanlon30-Jan-13 2:44
protectorPete O'Hanlon30-Jan-13 2:44 
GeneralRe: RoutedEvent vs AttachedEvent Pin
devvvy30-Jan-13 3:08
memberdevvvy30-Jan-13 3:08 
QuestionWPF Tab Item Close Button Pin
Kevin Marois29-Jan-13 18:03
memberKevin Marois29-Jan-13 18:03 
AnswerRe: WPF Tab Item Close Button Pin
SledgeHammer0129-Jan-13 19:02
memberSledgeHammer0129-Jan-13 19:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 18 Aug 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid