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