How can I automatically layout Grids Using the IsSharedSizeScope Property ?
Grids are useful in localizable applications to create controls that adjust to fit content. In the below example, the Grid element’s ‘IsSharedSizeScope’ attached property is useful for sharing the same sizing among multiple grid elements. [XAML] <StackPanel Orientation='Horizontal' DockPanel.Dock='Top'> <Button Click='setTrue' Margin='0,0,10,10'>Set IsSharedSizeScope='True'</Button> <Button Click='setFalse' Margin='0,0,10,10'>Set IsSharedSizeScope='False'</Button> </StackPanel> <StackPanel Orientation='Horizontal' DockPanel.Dock='Top'> <Grid ShowGridLines='True' Margin='0,0,10,0'> <Grid.ColumnDefinitions> <ColumnDefinition SharedSizeGroup='FirstColumn'/> <ColumnDefinition SharedSizeGroup='SecondColumn'/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height='Auto' SharedSizeGroup='FirstRow'/> </Grid.RowDefinitions> <Rectangle Fill='Silver' Grid.Column='0' Grid.Row='0' Width='200' Height='100'/> <Rectangle Fill='Blue' Grid.Column='1' Grid.Row='0' Width='150' Height='100'/> <TextBlock Grid.Column='0' Grid.Row='0' FontWeight='Bold'>First Column</TextBlock> <TextBlock Grid.Column='1' Grid.Row='0' FontWeight='Bold'>Second Column</TextBlock> </Grid> <Grid ShowGridLines='True'> <Grid.ColumnDefinitions> <ColumnDefinition SharedSizeGroup='FirstColumn'/> <ColumnDefinition SharedSizeGroup='SecondColumn'/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height='Auto' SharedSizeGroup='FirstRow'/> </Grid.RowDefinitions> <Rectangle Fill='Silver' Grid.Column='0' Grid.Row='0'/> <Rectangle Fill='Blue' Grid.Column='1' Grid.Row='0'/> <TextBlock Grid.Column='0' Grid.Row='0' FontWeight='Bold'>First Column</TextBlock> <TextBlock Grid.Column='1' Grid.Row='0' FontWeight='Bold'>Second Column</TextBlock> </Grid> </StackPanel> <TextBlock Margin='10' DockPanel.Dock='Top' Name='txt1'/>
How can users send e-mail using ASP.NET?
Here is an article from ftp online: Easy E-Mail-It’s About Time
How can I bind the Expander’s header element’s Width to the ActualWidth of the Expander ?
This can be done with the following code snippet.
How can I replace the style of a DocumentViewer ?
This can be done with the following code snippets, Define the required styles in the App.xaml file. [XAML] <Style x:Key="MyDVStyleExtend1" BasedOn="{StaticResource {x:Type DocumentViewer}}" TargetType="{x:Type DocumentViewer}"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Offset="0.0" Color="Red" /> <GradientStop Offset="1.0" Color="White" /> </LinearGradientBrush> </Setter.Value> </Setter> </Style> <Style x:Key="MyDVStyleExtend2" BasedOn="{StaticResource {x:Type DocumentViewer}}" TargetType="{x:Type DocumentViewer}"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Offset="0.0" Color="Blue" /> <GradientStop Offset="1.0" Color="White" /> </LinearGradientBrush> </Setter.Value> </Setter> </Style> Define the DocumentViewer in MainWindow. [XAML] <Grid> <DocumentViewer Name="MyDocumentViewer"/> <Button Content="Style1" Height="30" Width="100" Click="Button1_Click" /> <Button Content="Style2" Height="30" Width="100" Click="Button2_Click" /> </Grid> Replace the styles for document viewer based on button clicks from main window. [C#] private void Button1_Click(object sender, RoutedEventArgs e) { MyDocumentViewer.Style = (Style)Application.Current.Resources['MyDVStyleExtend1']; } private void Button2_Click(object sender, RoutedEventArgs e) { MyDocumentViewer.Style = (Style)Application.Current.Resources['MyDVStyleExtend2']; }
How can I animate the thickness of a border by using ThicknessAnimation ?
The following example animates the thickness of a border by using the ‘ThicknessAnimation’ property. The example uses the ’BorderThickness’ property of Border. [XAML] <!-- an animation on the BorderThickness property of a Border. --> <Page xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' > <StackPanel Orientation='Vertical' HorizontalAlignment='Center'> <Border Background='#99FFFFFF' BorderBrush='#CCCCFF' BorderThickness='1' Margin='0,60,0,20' Padding='20' > <Border.Triggers> <EventTrigger RoutedEvent='Border.Loaded'> <BeginStoryboard> <Storyboard> <!-- BorderThickness animates from left=1, right=1, top=1, and bottom=1 to left=28, right=28, top=14, and bottom=14 over one second. --> <ThicknessAnimation Storyboard.TargetProperty='BorderThickness' Duration='0:0:1.5' FillBehavior='HoldEnd' From='1,1,1,1' To='28,14,28,14' /> </Storyboard> </BeginStoryboard> </EventTrigger> </Border.Triggers> <TextBlock> This example shows how to use the ThicknessAnimation to create an animation on the BorderThickness property of a Border. </TextBlock> </Border> </StackPanel> </Page>