Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.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# WPF按钮赢得';t在WindowsState中点火=";“最大化”;_C#_Wpf_Xaml - Fatal编程技术网

C# WPF按钮赢得';t在WindowsState中点火=";“最大化”;

C# WPF按钮赢得';t在WindowsState中点火=";“最大化”;,c#,wpf,xaml,C#,Wpf,Xaml,我正在开发一个WPF应用程序,希望它能在设备上持续运行。因此,我希望它能够占用运行它的任何设备的最大屏幕大小。我可以让应用程序占据整个屏幕,但当我这样做时,我的任何按钮都不会启动。我必须调整窗口的大小,然后按钮就会启动。有人知道为什么会这样吗 XAML: <Window x:Class="ExchangeCalendar.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

我正在开发一个WPF应用程序,希望它能在设备上持续运行。因此,我希望它能够占用运行它的任何设备的最大屏幕大小。我可以让应用程序占据整个屏幕,但当我这样做时,我的任何按钮都不会启动。我必须调整窗口的大小,然后按钮就会启动。有人知道为什么会这样吗

XAML:

<Window x:Class="ExchangeCalendar.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525"
    WindowStartupLocation="CenterOwner" WindowState="Maximized" ResizeMode="NoResize">
<Window.Resources>
    <CollectionViewSource x:Key="CalendarDataSource"/>


</Window.Resources>

<Grid>
    <Button Content="Settings" HorizontalAlignment="Left" Margin="103,195,0,0" VerticalAlignment="Top" Width="75" Click="settings_btn"/>
    <Button Content="Add Meeting" HorizontalAlignment="Left" Margin="103,140,0,0" VerticalAlignment="Top" Width="75" Click="add_meeting_btn"/>
    <DataGrid Name ="CalendarData" HorizontalAlignment="Left" Height="251" Margin="196,61,0,0" VerticalAlignment="Top" Width="322" ItemsSource="{Binding Source={StaticResource CalendarDataSource}}"/>
    <Label Content="Utilimap Conference Room" Margin="49,10,67.4,261.4" FontWeight="Bold" FontSize="28"/>
    <Grid HorizontalAlignment="Left" Height="302" VerticalAlignment="Bottom" Width="508" Margin="10,0,0,10.4">
        <Grid.RowDefinitions>
            <RowDefinition Height="22*"/>
            <RowDefinition Height="129*"/>
        </Grid.RowDefinitions>
        <Label x:Name="Connection_lbl" Content="Label" HorizontalAlignment="Left" Margin="277,129,0,0" Grid.Row="1" VerticalAlignment="Top" Width="92" Visibility="Hidden"/>
    </Grid>

</Grid>

代码隐藏:

public partial class MainWindow : Window
{
    #region Properties_and_variables
    /*Properties*/
    private String Domain { get; set; }
    private String SharedCal { get; set; }
    private String username { get; set; }
    private String Password { get; set; }
    private ExchangeVersion version { get; set; }
    public List<MeetingData> Appointments { get; set; }

    /*Variables*/
    private ExchangeService service;
    private bool validCredentials = true;
    private FolderId shareFolderId;
    private CalendarView calendar;
    #endregion

    public MainWindow()
    {
        InitializeComponent();
        this.Appointments = new List<MeetingData>();

    }

    #region Buttons

    /*Settings Button clicked*/
    private void settings_btn(object sender, RoutedEventArgs e)
    {
        SettingsDialog op = new SettingsDialog();

        if ((bool)op.ShowDialog(this.username, this.Password, this.SharedCal, this.Domain, this.version)){
            set_setting_properties(op);
            connect_to_exchange();
        }
    }

    //Add Meeting Button Clicked
    private void add_meeting_btn(object sender, RoutedEventArgs e)
    {
        //Create new dialog for adding a meeting
        AddMeeting meetingToAdd = new AddMeeting();
        bool[] results = room_availability();
        MeetingData newMeeting = new MeetingData("", "", "", "WinExchangeCalendar", 60);

        //Get user data
        if (meetingToAdd.ShowDialog(newMeeting, results))
            add_new_meeting_to_cal(newMeeting);

    }
公共部分类主窗口:窗口
{
#区域属性和变量
/*性质*/
私有字符串域{get;set;}
私有字符串SharedCal{get;set;}
私有字符串用户名{get;set;}
私有字符串密码{get;set;}
私有ExchangeVersion版本{get;set;}
公共列表约会{get;set;}
/*变数*/
私人交换服务;
private bool validCredentials=真;
私有文件夹ID shareFolderId;
私人日历查看日历;
#端区
公共主窗口()
{
初始化组件();
this.appoints=新列表();
}
#区域按钮
/*单击设置按钮*/
私有无效设置\u btn(对象发送方,路由目标)
{
SettingsDialog op=新建SettingsDialog();
if((bool)op.ShowDialog(this.username、this.Password、this.SharedCal、this.Domain、this.version)){
设置设置属性(op);
将_连接到_交换();
}
}
//单击“添加会议”按钮
私有无效添加会议(对象发送方,路由目标)
{
//创建用于添加会议的新对话框
AddMeeting Meeting ToAdd=新的AddMeeting();
bool[]结果=房间可用性();
MeetingData newMeeting=新会议数据(“,”,“,”,“WinExchange日历”,60);
//获取用户数据
if(会议到添加显示对话框(新会议,结果))
将新会议添加到cal(新会议);
}

尝试设置
垂直对齐=“顶部”
标签
相对,因为它覆盖了
按钮
,但作为长期解决方案,使用不同的布局面板,如
DockPanel
或定义
网格中的行/列
,而不是通过
边距
定位元素,并固定
宽度
/
高度
,尤其是t您不想占用所有可用空间。
按钮出现的任何问题都与全屏应用程序无关。要确认这一点,请创建一个新项目,使其全屏显示,添加一个
按钮并单击它。您将看到处理程序按预期调用。因此,它很可能是全屏应用程序您的一些代码导致了问题。@Sheridan我肯定是我的代码导致了问题,但我很困惑,因为如果我只是移动窗口,它将缩小到350x525大小,然后按钮将启动。这就是为什么我认为它是链接的。有时当我们遇到这样的问题时,我们唯一能做的就是找到问题m是尝试在一个简单的项目中重新创建它。因此,如果您启动一个新项目并将即时代码一点一点地复制到其中,通常会发生以下两种情况之一:要么您会发现新项目没有问题,在这种情况下您应该能够发现差异,要么它会有问题,在这种情况下您可以在这里测试它。基本部分是删除所有不相关的代码,比如
ExchangeService
相关类。