SilverLight中d出自定义模态窗口

SilverLight中d出自定义模态窗口,第1张

概述SilverLight中d出自定义模态窗口   1.       建立Child窗口类 DemoChildWindow前台代码: <basics:ChildWindow x:Class="System.Windows.Controls.Samples.DemoChildWindow"            xmlns="http://schemas.microsoft.com/winfx/2006

Silverlight中d出自定义模态窗口

 

1.       建立Child窗口类

DemoChilDWindow前台代码:

<basics:ChilDWindow x:Class="System.windows.Controls.Samples.DemoChilDWindow"

           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

           xmlns:basics="clr-namespace:System.windows.Controls;assembly=System.windows.Controls"

           xmlns:dataform="clr-namespace:System.windows.Controls;assembly=System.windows.Controls.Data.DataForm.Toolkit"

           WIDth="400" Height="300"

           @R_502_5979@="Childwindowsample">

    <GrID margin="2">

        <GrID.RowDeFinitions>

            <RowDeFinition />

            <RowDeFinition Height="auto" />

            <RowDeFinition Height="auto" />

        </GrID.RowDeFinitions>

 

        <ContentControl HorizontalAlignment="Center" VerticalAlignment="Center" Content="{Binding}" />

        <StackPanel GrID.Row="1" x:name="optionsstack">

            <GrID HorizontalAlignment="Stretch">

                <GrID.ColumnDeFinitions>

                    <ColumnDeFinition WIDth="auto" />

                    <ColumnDeFinition />

                </GrID.ColumnDeFinitions>

                <TextBlock Text="OverlayOpacity: " margin="4" HorizontalAlignment="Stretch" />

                <SlIDer GrID.Column="1" Minimum="0" IsEnabled="True" Maximum="1" Value="{Binding OverlayOpacity, Mode=TwoWay}" HorizontalAlignment="Stretch" />

            </GrID>

            <GrID HorizontalAlignment="Stretch">

                <GrID.ColumnDeFinitions>

                    <ColumnDeFinition WIDth="auto" />

                    <ColumnDeFinition />

                </GrID.ColumnDeFinitions>

                <TextBlock Text="Overlay Brush: " margin="4" />

                <ComboBox SelectedItem="{Binding OverlayBrush, Mode=TwoWay}" GrID.Column="1" IsEnabled="True" HorizontalAlignment="Stretch">

                    <ComboBox.ItemTemplate>

                        <DataTemplate>

                            <StackPanel OrIEntation="Horizontal">

                                <TextBlock margin="2" Text="{Binding color}" FontFamily="Consolas" VerticalAlignment="Center" />

                                <Rectangle Fill="{Binding}" margin="2" stroke="Black" Height="14" WIDth="75" />

                            </StackPanel>

                        </DataTemplate>

                    </ComboBox.ItemTemplate>

                    <SolIDcolorBrush color="White" Opacity=".7"  />

                    <SolIDcolorBrush color="Black" Opacity=".7" />

                    <SolIDcolorBrush color="Blue" Opacity=".7" />

                    <SolIDcolorBrush color="Yellow" Opacity=".7" />

                    <SolIDcolorBrush color="Pink" Opacity=".7" />

                    <SolIDcolorBrush color="Orange" Opacity=".7" />

                    <SolIDcolorBrush color="Green" Opacity=".7" />

                    <SolIDcolorBrush color="Red" Opacity=".7" />

                </ComboBox>

            </GrID>

        </StackPanel>

        <button Content="Cancel" Click="Cancelbutton_Click" WIDth="75" Height="23" HorizontalAlignment="Right" margin="0,12,0" GrID.Row="2" />

        <button Content="OK" Click="OKbutton_Click" WIDth="75" Height="23" HorizontalAlignment="Right"  margin="0,79,0" GrID.Row="2" />

    </GrID>

</basics:ChilDWindow>

DemoChilDWindow后台代码

namespace System.windows.Controls.Samples

{

    /// <summary>

    /// Sample ChilDWindow for demonstration purposes.

    /// </summary>

    public partial class DemoChilDWindow : ChilDWindow

    {

        /// <summary>

        /// Initializes a DemoChilDWindow.

        /// </summary>

        public DemoChilDWindow()

        {

            InitializeComponent();

            optionsstack.DataContext = this;

        }

 

        /// <summary>

        /// Handles the Click event of the OK button.

        /// </summary>

        /// <param name="sender">OK button.</param>

        /// <param name="e">Event arguments.</param>

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance","CA1811:AvoIDUncalledPrivateCode",Justification = "Used by event defined in Xaml.")]

        private voID OKbutton_Click(object sender,RoutedEventArgs e)

        {

            this.DialogResult = true;

        }

 

        /// <summary>

        /// Handles the Click event of the Cancel button.

        /// </summary>

        /// <param name="sender">Cancel button.</param>

        /// <param name="e">Event arguments.</param>

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",Justification = "Used by event defined in Xaml.")]

        private voID Cancelbutton_Click(object sender,RoutedEventArgs e)

        {

            this.DialogResult = false;

        }

    }

}

 

2.       调用

using System.ComponentModel;

using System.linq;

 

namespace System.windows.Controls.Samples

{

    /// <summary>

    /// Sample page demonstrating the ChilDWindow.

    /// </summary>

    [Sample("ChilDWindow",DifficultyLevel.Basic)]

    [category("ChilDWindow")]

    public partial class Childwindowsample : UserControl

    {

        /// <summary>

        /// Keeps an instance of a ChilDWindow that will be shown when a button is clicked.

        /// </summary>

        private DemoChilDWindow dcw;

 

        /// <summary>

        /// Initializes a new instance of the Childwindowsample class.

        /// </summary>

        public Childwindowsample()

        {

            InitializeComponent();

            dcw = new DemoChilDWindow();

            dcw.Closed += new EventHandler(Dcw_Closed);

            thumbs.ItemsSource = from p in Photograph.GetPhotographs()

                                 orderby p.name

                                 select p;

            thumbs.Selectedindex = 0;

        }

 

        /// <summary>

        /// Handles the "Closed" event of the ChilDWindow.

        /// </summary>

        /// <param name="sender">Child Window.</param>

        /// <param name="e">Event Arguments.</param>

        private voID Dcw_Closed(object sender,EventArgs e)

        {

            dialogResult.Text = dcw.DialogResult.ToString();

        }

 

        /// <summary>

        /// Handles clicking the "Show" button.

        /// </summary>

        /// <param name="sender">Clicked button.</param>

        /// <param name="e">Event Arguments.</param>

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",Justification = "Used by event defined in Xaml.")]

        private voID button_Click(object sender,RoutedEventArgs e)

        {

            dcw.@R_502_5979@ = @[email protected];

            dcw.DataContext = (from p in Photograph.GetPhotographs()

                               where p.name.Equals((thumbs.SelectedItem as Photograph).name)

                               select p).First().Image;

            dcw.Show();

        }

    }

}

总结

以上是内存溢出为你收集整理的SilverLight中d出自定义模态窗口全部内容,希望文章能够帮你解决SilverLight中d出自定义模态窗口所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1047408.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)