Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用弹出窗口的WP7 silverlight自定义控件_C#_Silverlight_Windows Phone 7 - Fatal编程技术网

C# 使用弹出窗口的WP7 silverlight自定义控件

C# 使用弹出窗口的WP7 silverlight自定义控件,c#,silverlight,windows-phone-7,C#,Silverlight,Windows Phone 7,我正在创建一个自定义日期选择器,我有一个文本框,一旦点击它就会在弹出窗口中打开一个日历。 我想做的是更改弹出窗口的大小,使其显示我的整个日历,但我无法更改它…,我已尝试使用高度、宽度、最小高度、最小宽度。。。但它不工作,弹出窗口以固定大小显示 问题是,我的弹出窗口的父属性没有计算,因为它有表达式问题(根据调试器),所以我确定我的弹出窗口的父属性不是主屏幕(比如布局网格) 例如,如何在特定上下文中打开弹出窗口? 我的这部分代码不是XAML,它只是C代码,看起来像: using System; us

我正在创建一个自定义日期选择器,我有一个文本框,一旦点击它就会在弹出窗口中打开一个日历。 我想做的是更改弹出窗口的大小,使其显示我的整个日历,但我无法更改它…,我已尝试使用高度、宽度、最小高度、最小宽度。。。但它不工作,弹出窗口以固定大小显示

问题是,我的弹出窗口的父属性没有计算,因为它有表达式问题(根据调试器),所以我确定我的弹出窗口的父属性不是主屏幕(比如布局网格)

例如,如何在特定上下文中打开弹出窗口? 我的这部分代码不是XAML,它只是C代码,看起来像:

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;

namespace CalendarBranch.components
{
    public class wpDatePicker:TextBox
    {
        private CalendarPopup calendar;
        private Popup popup;

        public wpDatePicker()
        {
            this.calendar = new CalendarPopup();
            this.popup = new Popup();

            this.popup.Child = this.calendar;
            this.popup.Margin = new Thickness(0);

            this.MouseLeftButtonUp += new MouseButtonEventHandler(wpDatePicker_MouseLeftButtonUp);

            this.calendar.onDateSelect += new EventHandler(onDateSelected);

            this.IsReadOnly = true;

        }

        protected void wpDatePicker_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            this.popup.Height = this.calendar.Height;
            this.popup.Width = this.calendar.Width;
            this.popup.HorizontalAlignment = HorizontalAlignment.Center;
            this.popup.VerticalAlignment = VerticalAlignment.Center;
            this.popup.HorizontalOffset = 0;
            this.popup.VerticalOffset = 0;
            this.popup.MinHeight = this.calendar.Height;
            this.popup.MinWidth = this.calendar.Width;

            this.popup.IsOpen = true;
        }

        private void onDateSelected(Object sender, EventArgs ea) {
            this.Text = this.calendar.SelectedValue.ToShortDateString();
            this.popup.IsOpen = false;
        }

    }
}
PS:class Calendar只是一个用户控件,它包含一个包含多列、超链接按钮和文本块的网格,所以没有什么特别的

提前谢谢大家;)

干杯
Miloud B.

弹出控件调整自身大小以适应其内部内容。例如,如果将弹出窗口的子对象设置为StackPanel,且宽度/高度设置为100,则弹出窗口将为100x100


因此,设置弹出窗口的大小,而是设置内部面板的大小非常重要。尝试将内容包装到stackpanel中,并在其中指定必要的宽度/高度。

我建议您快速阅读降价文档(编辑问题时,右侧有一个摘要)。好的。那我现在的问题呢?