Gets the control instance method for a resource dictionary control template

Source: Internet
Author: User

Messageboxgeneric.xaml

<ResourceDictionaryxmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local= "Clr-namespace:jetsun.presentation"Xmlns:js= "Clr-namespace:jetsun.presentation.markups">    <StyleTargetType= "Local:messageboxcontrol">        <Setter Property= "Template">            <Setter.value>                <ControlTemplateTargetType= "Local:messageboxcontrol">                    <Gridflowdirection="{Binding Contentflowdirection}"MaxWidth= "All">                        <grid.rowdefinitions>                            <RowDefinitionHeight= " on" />                            <RowDefinitionHeight="*" />                            <RowDefinitionHeight="*" />                            <RowDefinitionHeight= "Auto" />                        </grid.rowdefinitions>                        <grid.columndefinitions>                            <ColumnDefinitionWidth= "Auto" />                            <ColumnDefinitionWidth="*" />                        </grid.columndefinitions>                        <ImageSource="{Binding Messageimagesource}"HorizontalAlignment= "Left"VerticalAlignment= "Center"Height= "+"Width= "+"Margin= "0 0 0" />                        <TextBlockText="{Binding Message}"Grid.rowspan= "2"Grid.column= "1"textwrapping= "Wrap"TextAlignment= "Left"HorizontalAlignment="{Binding Contenttextalignment}"VerticalAlignment= "Center"Margin= " Ten Ten" />                        <BorderGrid.Row= "3"Grid.column= "0"Grid.columnspan= "2"borderthickness= "0 1 0 0"Margin= "3">                            <StackPanelOrientation= "Horizontal"VerticalAlignment= "Center"HorizontalAlignment= "Right"Margin= "0 0 5 0" >                                <ButtonContent= "Yes"Visibility="{Binding yesnovisibility}"Command="{Binding Yescommand}"IsDefault="{Binding Isyesdefault}"Margin= "5 5 5 5"Width= "a"x:name= "Part_yesbutton"Istabstop= "True"TabIndex= "0"/>                                <ButtonContent= "No"Visibility="{Binding yesnovisibility}"Command="{Binding Nocommand}"IsDefault="{Binding Isnodefault}"Margin= "5 5 5 5"Width= "a"x:name= "Part_nobutton"Istabstop= "True"TabIndex= "1" />                                <ButtonContent= "Confirm"Visibility="{Binding okvisibility}"Command="{Binding Okcommand}"IsDefault="{Binding Isokdefault}"Margin= "5 5 5 5"Width= "a"x:name= "Part_okbutton"Istabstop= "True"TabIndex= "2" />                                <ButtonContent= "Cancel"Visibility="{Binding cancelvisibility}"Command="{Binding CancelCommand}"IsDefault="{Binding Iscanceldefault}"Margin= "5 5 5 5"Width= "a"x:name= "Part_cancelbutton"Istabstop= "True"TabIndex= "3" />                            </StackPanel>                        </Border>                    </Grid>                </ControlTemplate>            </Setter.value>        </Setter>    </Style></ResourceDictionary>


Remove the control instance method for the control template:

     Public classMessageboxcontrol:control {StaticMessageboxcontrol () {Defaultstylekeyproperty.overridemetadata (typeof(Messageboxcontrol),NewFrameworkpropertymetadata (typeof(Messageboxcontrol)));        } Button _btnyes;        Button _btnno;        Button _btnok;        Button _btncancel;  Public Override voidOnApplyTemplate () {Base.            OnApplyTemplate (); _btnyes= GetTemplateChild ("Part_yesbutton") asButton; _btnno= GetTemplateChild ("Part_nobutton") asButton; _btnok= GetTemplateChild ("Part_okbutton") asButton; _btncancel= GetTemplateChild ("Part_cancelbutton") asButton; }        protected Override voidOnGotFocus (RoutedEventArgs e) {Messageboxviewmodel model= This. DataContext asMessageboxviewmodel; if(model.            Isyesdefault) {_btnyes.focus ();} if(model.            Isnodefault) {_btnno.focus ();} if(model.            Isokdefault) {_btnok.focus ();} if(model.        Iscanceldefault) {_btncancel.focus ();} }    }

Gets the control instance method for a resource dictionary control template

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.