弹出子窗口应用

===========子窗口========ChildWindowShow==========

<controls:ChildWindow x:Class="SilverlightSocket.ChildWindowShow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" Width="400" Height="300" Title="ChildWindowShow">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
<Image x:Name="imgContent" Grid.Row="0" Grid.Column="0"></Image>'定义一个图片
        <Button x:Name="CancelButton" Content="取消" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1"/>
        <Button x:Name="OKButton" Content="确定" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1"/>
    </Grid>
</controls:ChildWindow>
===========XAML===========

<UserControl x:Class="SilverlightSocket.openwindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     >
    <StackPanel x:Name="LayoutRoot" Orientation="Horizontal">
        <StackPanel.Background>
            <ImageBrush ImageSource="/Images/win7-12.jpg" Stretch="UniformToFill"/>
        </StackPanel.Background>
    </StackPanel>
</UserControl>
=================VB==================

Imports System.Windows.Media.Imaging

Partial Public Class openwindow
    Inherits UserControl

    Public Sub New()
        InitializeComponent()
        BuildElement()
    End Sub
    Public Sub BuildElement()
        For i = 1 To 5
            Dim uri As New Uri(String.Format("Images/win7-{0}.jpg", i), UriKind.RelativeOrAbsolute) ''''定义URI对象
            Dim btn As New Button
            Dim img As New Image()
            img.Width = 150
            img.Height = 150
            img.Stretch = Stretch.Fill
            img.Source = New BitmapImage(uri)
            btn.Width = 150
            btn.Height = 150
            btn.Margin = New Thickness(5)
            btn.Content = img
            'AddHandler btn.Click, (AddressOf btn_click(btn, Button))
            ' btn.Click += New Button
            'ck1.Click+=new System.EventHandler(MyClick
            ' New EventHandler(Of wcfsilverlight.ServiceReference1.GetLogCompletedEventArgs)
            AddHandler btn.Click, New RoutedEventHandler(AddressOf btn_click)
            LayoutRoot.Children.Add(btn)

        Next

    End Sub
    Public Sub btn_click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Dim btn As Button = sender
        Dim cw As New ChildWindowShow
        Dim img As Image = btn.Content
        cw.imgContent.Source = img.Source
        cw.Show()

    End Sub
End Class

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值