WPF按钮不会在windowState ="最大化"

时间:2014-08-07 15:00:02

标签: c# wpf xaml

我正在开发一个我希望在设备上不断运行的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);

    }

0 个答案:

没有答案