因此,我在测试UWP应用程序时,发现按钮和条件格式有些奇怪。
该应用会查看当天的内容,并根据当天确定要显示的按钮。
如果不是所讨论的日期,则显示以下内容: https://firebase.google.com/docs/firestore/manage-data/transactions?authuser=1#batched-writes
但是如果我回去并将日期更改为符合条件的适当日期,则会显示以下内容:
如果我在进入有问题的页面之前已经选择了正确的条件日,那么我将获得正确的格式:
有什么想法吗?
XAML代码段:
<Button Name="CHWPButton"
RelativePanel.AlignLeftWithPanel="True"
FontSize="16"
FontWeight="Bold"
Width="135"
Height="50"
Style="{StaticResource EQButton}"
Margin="50,10,45,10"
Content="CHWP"
Click="CHWPButton_Click">
</Button>
<Button Name="AHU1A2B7AButton"
RelativePanel.AlignVerticalCenterWith="CHWPButton"
RelativePanel.RightOf="CHWPButton"
FontSize="16"
FontWeight="Bold"
Width="135"
Height="50"
Style="{StaticResource EQButton}"
Margin="0,0,45,0"
Content="AHU 1A/2B/7A"
Click="AHU1A2B7AButton_Click">
</Button>
<Button Name="AHU2B3C4D9C10DButton"
RelativePanel.AlignVerticalCenterWith="CHWPButton"
RelativePanel.RightOf="AHU1A2B7AButton"
FontSize="10"
FontWeight="Bold"
Width="135"
Height="50"
Style="{StaticResource EQButton}"
Margin="0,0,45,0"
Content="AHU 2B/3C/4D/9C/10D"
Click="AHU2B3C4D9C10DButton_Click">
</Button>
<Button Name="AHU4D5E6RButton"
RelativePanel.AlignVerticalCenterWith="CHWPButton"
RelativePanel.RightOf="AHU2B3C4D9C10DButton"
FontSize="16"
FontWeight="Bold"
Width="135"
Height="50"
Style="{StaticResource EQButton}"
Margin="0,0,45,0"
Content="AHU 4D/5E/6R"
Click="AHU4D5E6RButton_Click">
</Button>
<Button Name="AHURoom3020Button"
RelativePanel.Below="CHWPButton"
RelativePanel.AlignLeftWithPanel="True"
FontSize="16"
FontWeight="Bold"
Width="135"
Height="50"
Style="{StaticResource EQButton}"
Margin="50,10,45,10"
Content="Room 3020"
Click="AHURoom3020Button_Click">
</Button>
<Button Name="AHU22D23E24RButton"
RelativePanel.RightOf="AHURoom3020Button"
RelativePanel.AlignVerticalCenterWith="AHURoom3020Button"
FontSize="12"
FontWeight="Bold"
Width="135"
Height="50"
Style="{StaticResource EQButton}"
Margin="0,0,45,0"
Content="AHU 22D/23E/24R"
Click="AHU22D23E24RButton_Click">
</Button>
<Button Name="AHU19A20B21CButton"
RelativePanel.RightOf="AHU22D23E24RButton"
RelativePanel.AlignVerticalCenterWith="AHURoom3020Button"
FontSize="12"
FontWeight="Bold"
Width="135"
Height="50"
Style="{StaticResource EQButton}"
Margin="0,0,45,0"
Content="AHU 19A/20B/21C"
Click="AHU19A20B21CButton_Click">
</Button>
<Button Name="AHU10D11E12RButton"
RelativePanel.RightOf="AHU19A20B21CButton"
RelativePanel.AlignVerticalCenterWith="AHURoom3020Button"
FontSize="12"
FontWeight="Bold"
Width="135"
Height="50"
Style="{StaticResource EQButton}"
Margin="0,0,45,0"
Content="AHU 10D/11E/12R"
Click="AHU10D_11E_12RButton_Click">
</Button>
还有C#文件部分:
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using DC6Rounds.Pages;
using Windows.ApplicationModel.Core;
using Windows.UI;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Microsoft.Identity.Client;
using System.Linq;
using Windows.UI.Popups;
namespace DC6Rounds
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void IconsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (GeneralListBoxItem.IsSelected)
{
FrameContent.Navigate(typeof(GeneralPage));
Title.Text = "General";
SignInButtonStatus();
GeneralPageButton.Visibility = Visibility.Visible;
BMSButton.Visibility = Visibility.Visible;
WeeklyPeakReadingsButtonStatus();
ColdWeatherButtonStatus();
}
else if (MechanicalPenthouseListBoxItem.IsSelected)
{
if (App.Day == "Tue")
{
FrameContent.Navigate(typeof(AHU1A2B7APage));
Title.Text = "AHU 1A/2B/7A";
}
else
{
FrameContent.Navigate(typeof(CHWPPage));
Title.Text = "CHWP";
}
MechanicalPenthouseButtons();
}
}
public void HideButtons()
{
//Main Buttons
SubmitButton.Visibility = Visibility.Collapsed;
SignInButton.Visibility = Visibility.Collapsed;
SignOutButton.Visibility = Visibility.Collapsed;
FileButton.Visibility = Visibility.Collapsed;
//Mechanical Penthouse Buttons
AHU1A2B7AButton.Visibility = Visibility.Collapsed; //Button 1
AHU2B3C4D9C10DButton.Visibility = Visibility.Collapsed; //Button 2
AHU4D5E6RButton.Visibility = Visibility.Collapsed; //Button 3
MainPenthouseButton.Visibility = Visibility.Collapsed; //Button 4
CHWPButton.Visibility = Visibility.Collapsed; //Button 5
AHU13A14B15CButton.Visibility = Visibility.Collapsed; // Button 6
AHU15C16D17E21C22DButton.Visibility = Visibility.Collapsed; // Button 7
AHU17E18R24RButton.Visibility = Visibility.Collapsed; // Button 8
AHURoom3020Button.Visibility = Visibility.Collapsed; // Button 9
AHU22D23E24RButton.Visibility = Visibility.Collapsed; // Button 10
AHU19A20B21CButton.Visibility = Visibility.Collapsed; // Button 11
AHU10D11E12RButton.Visibility = Visibility.Collapsed; //Button 12
AHU7A8B9CButton.Visibility = Visibility.Collapsed; //Button 13
}
public void MechanicalPenthouseButtons()
{
if(App.Day == "Tue")
{
SignInButtonStatus();
AHU1A2B7AButton.Visibility = Visibility.Visible; //Button 1
AHU2B3C4D9C10DButton.Visibility = Visibility.Visible; //Button 2
AHU4D5E6RButton.Visibility = Visibility.Visible; //Button 3
MainPenthouseButton.Visibility = Visibility.Visible; //Button 4
CHWPButton.Visibility = Visibility.Visible; //Button 5
AHU13A14B15CButton.Visibility = Visibility.Visible; // Button 6
AHU15C16D17E21C22DButton.Visibility = Visibility.Visible; // Button 7
AHU17E18R24RButton.Visibility = Visibility.Visible; // Button 8
AHURoom3020Button.Visibility = Visibility.Visible; // Button 9
AHU22D23E24RButton.Visibility = Visibility.Visible; // Button 10
AHU19A20B21CButton.Visibility = Visibility.Visible; // Button 11
AHU10D11E12RButton.Visibility = Visibility.Visible; //Button 12
AHU7A8B9CButton.Visibility = Visibility.Visible; //Button 13
}
else
{
SignInButtonStatus();
CHWPButton.Visibility = Visibility.Visible; //Button 5
CHWPButton.Margin = new Thickness(50, 10, 0, 0);
AHURoom3020Button.Visibility = Visibility.Visible; //Button 9
AHURoom3020Button.Margin = new Thickness(50, 10, 0, 0);
}
}
public void SignInButtonStatus()
{
if (SignInButton.Visibility == Visibility.Collapsed)
{
HideButtons();
SignOutButton.Visibility = Visibility.Visible;
}
else
{
HideButtons();
SignInButton.Visibility = Visibility.Visible;
}
SaveNotesButton.Visibility = Visibility.Visible;
}
}
}
答案 0 :(得分:0)
我知道了。我自己做的我最初在页面中间设置了这两个按钮,所以我修改了它们的边距,但是我使用了不同的数字。
public void MechanicalPenthouseButtons()
{
if(App.Day == "Tue")
{
SignInButtonStatus();
AHU1A2B7AButton.Visibility = Visibility.Visible; //Button 1
AHU2B3C4D9C10DButton.Visibility = Visibility.Visible; //Button 2
AHU4D5E6RButton.Visibility = Visibility.Visible; //Button 3
MainPenthouseButton.Visibility = Visibility.Visible; //Button 4
CHWPButton.Visibility = Visibility.Visible; //Button 5
AHU13A14B15CButton.Visibility = Visibility.Visible; // Button 6
AHU15C16D17E21C22DButton.Visibility = Visibility.Visible; // Button 7
AHU17E18R24RButton.Visibility = Visibility.Visible; // Button 8
AHURoom3020Button.Visibility = Visibility.Visible; // Button 9
AHU22D23E24RButton.Visibility = Visibility.Visible; // Button 10
AHU19A20B21CButton.Visibility = Visibility.Visible; // Button 11
AHU10D11E12RButton.Visibility = Visibility.Visible; //Button 12
AHU7A8B9CButton.Visibility = Visibility.Visible; //Button 13
}
else
{
SignInButtonStatus();
CHWPButton.Visibility = Visibility.Visible; //Button 5
CHWPButton.Margin = new Thickness(50, 10, 45, 10); // Was (50,10,0,0)
AHURoom3020Button.Visibility = Visibility.Visible; //Button 9
AHURoom3020Button.Margin = new Thickness(50, 10, 45, 10); // Was (50,10,0,0)
}
}