我想创建一个资金管理应用程序,我使用标签栏导航(只是编辑应用程序模板)应用程序有4个标签:收入,收入,统计和历史。
由于收入和支出操作几乎相同,因此收入和支出具有相同的DataTemplate
我创建了类BudgetOperation来表示我的收入和支出
public class BudgetOperation
{
private long id;
private float amount;
private DateTime date;
private string description;
private OperationCategory operationCategory; //I mean source of money (salary, pocket monet etc)
// or on what we spent money (food, transport etc)
private OperationType operationType;//Income or Expense
}
字符串
用户应该输入有关我的OperationPage他的操作的一些信息,这样我就可以收集的钱,并从页面上的评论量,分配操作时将创建日期,对我来说主要的问题是要确定它是收入或费用。为了解决这个问题,我想检查费用标签是否打开其费用操作,如果收入其收入
请给予我的意见,我如何才能确定活动标签的标签栏或其他一些方式来确定我的操作类型
下面是我的OperationPage.xaml代码
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Money_Manager.Views.OperationPage"
x:Name="currentPage">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Button">
<Setter Property="TextColor" Value="Black"/>
<Setter Property="CornerRadius" Value="15"/>
<Setter Property="BackgroundColor" Value="Transparent"/>
<Setter Property="FontSize" Value="25"/>
<!--<Setter Property="BorderColor" Value="{StaticResource Expence}"/>-->
<Setter Property="BorderWidth" Value="2"/>
</Style>
<Style TargetType="Label">
<Setter Property="TextColor" Value="Black"></Setter>
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<Grid>
<Frame x:Name="mainFrame" Grid.ColumnSpan ="6" Grid.RowSpan="8" BorderColor="Black" CornerRadius="0"
Opacity="1" BackgroundColor="Transparent" IsEnabled="False">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.125*"/>
<ColumnDefinition Width="0.25*"/>
<ColumnDefinition Width="0.25*"/>
<ColumnDefinition Width="0.25*"/>
<ColumnDefinition Width="0.125*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.2*"/>
<RowDefinition Height="0.2*"/>
<RowDefinition Height="0.12*"/>
<RowDefinition Height="0.12*"/>
<RowDefinition Height="0.12*"/>
<RowDefinition Height="0.12*"/>
<RowDefinition Height="0.12*"/>
</Grid.RowDefinitions>
<Label x:Name="amountLabel" Text="" TextDecorations="Underline" Grid.Row="0" Grid.ColumnSpan="5" Grid.Column="0"
HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="45"/>
<Label Text="Category" TextDecorations="Underline" Grid.Row="1" Grid.ColumnSpan="3" Grid.Column="1"
HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="45" />
<Button x:Name="scrollLeftButton" Grid.Row="1" Grid.Column="4" Grid.ColumnSpan="1" Text="R" FontSize="10" Clicked="ScrollLeftButton_Clicked"/>
<Button x:Name="scrollRightButton" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Text="L" FontSize="10" Clicked="ScrollRightButton_Clicked"/>
<Button x:Name="button1" Grid.Row="2" Grid.Column="1" Grid.RowSpan="1" Text="1" Clicked="Button1_Clicked"/>
<Button x:Name="button2" Grid.Row="2" Grid.Column="2" Grid.RowSpan="1" Text="2" Clicked="Button2_Clicked"/>
<Button x:Name="button3" Grid.Row="2" Grid.Column="3" Grid.RowSpan="1" Text="3" Clicked="Button3_Clicked"/>
<Button x:Name="button4" Grid.Row="3" Grid.Column="1" Grid.RowSpan="1" Text="4" Clicked="Button4_Clicked"/>
<Button x:Name="button5" Grid.Row="3" Grid.Column="2" Grid.RowSpan="1" Text="5" Clicked="Button5_Clicked"/>
<Button x:Name="button6" Grid.Row="3" Grid.Column="3" Grid.RowSpan="1" Text="6" Clicked="Button6_Clicked"/>
<Button x:Name="button7" Grid.Row="4" Grid.Column="1" Grid.RowSpan="1" Text="7" Clicked="Button7_Clicked"/>
<Button x:Name="button8" Grid.Row="4" Grid.Column="2" Grid.RowSpan="1" Text="8" Clicked="Button8_Clicked"/>
<Button x:Name="button9" Grid.Row="4" Grid.Column="3" Grid.RowSpan="1" Text="9" Clicked="Button9_Clicked"/>
<Button x:Name="dotButton" Grid.Row="5" Grid.Column="1" Grid.RowSpan="1" Text="." Clicked="DotButton_Clicked"/>
<Button x:Name="button0" Grid.Row="5" Grid.Column="2" Grid.RowSpan="1" Text="0" Clicked="Button0_Clicked"/>
<Button x:Name="deleteButton" Grid.Row="5" Grid.Column="3" Grid.RowSpan="1" Text="(--" Clicked="DeleteButton_Clicked"/>
<Button x:Name="commentButton" Grid.Row="6" Grid.Column="1" Grid.RowSpan="1" Text="Comment" FontSize="8" Clicked="CommentButton_Clicked"/>
<Button x:Name="saveButton" Grid.Row="6" Grid.Column="2" Grid.RowSpan="1" Text="Save" FontSize="10"
Clicked="SaveButton_Clicked" />
<Button x:Name="clearAllButton" Grid.Row="6" Grid.Column="3" Grid.RowSpan="1" Text="Clear all" FontSize="9" Clicked="ClearAllButton_Clicked"/>
</Grid>
</Frame>
<Frame x:Name="commentFrame"
BorderColor="Black" Grid.ColumnSpan="4" Grid.RowSpan="6" Grid.Column="1" Grid.Row="1"
CornerRadius="10" Opacity="1"
IsVisible="False">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.85*"/>
<RowDefinition Height="0.15*"/>
</Grid.RowDefinitions>
<Editor x:Name="commentEditorField" Grid.ColumnSpan="2" VerticalOptions="FillAndExpand" Keyboard="Text" TextColor="Black"/>
<Button x:Name="commentSaveButton" Grid.Row="1" Grid.Column="0" Text="Сохранить" FontSize="11" Clicked="CommentSaveButton_Clicked"/>
<Button x:Name="commentCancelButton" Grid.Row="1" Grid.Column="1" Text="Отменить" FontSize="11" Clicked="CommentCancelButton_Clicked"/>
</Grid>
</Frame>
</Grid>
</ContentPage>
型
这里看起来像
enter image description here
我的AppShell.xaml代码
<?xml version="1.0" encoding="UTF-8"?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Money_Manager.Views"
Title="Money_Manager"
x:Class="Money_Manager.AppShell"
x:Name="myShell">
<!--
The overall app visual hierarchy is defined here, along with navigation.
https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/
-->
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="Shell.ForegroundColor" Value="White" />
<Setter Property="Shell.TitleColor" Value="White" />
<Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
<Setter Property="Shell.TabBarBackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="Shell.TabBarForegroundColor" Value="White"/>
<Setter Property="Shell.TabBarUnselectedColor" Value="#95FFFFFF"/>
<Setter Property="Shell.TabBarTitleColor" Value="White"/>
</Style>
<Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="FlyoutItem" BasedOn="{StaticResource BaseStyle}" />
</ResourceDictionary>
</Shell.Resources>
<TabBar x:Name="tabBar">
<ShellContent x:Name="expencesTab" Title="Расход" Icon="icon_expence.png" ContentTemplate="{DataTemplate local:OperationPage}"
Shell.BackgroundColor="{StaticResource Expence}" Shell.TabBarBackgroundColor="{StaticResource Expence}"/>
<ShellContent x:Name="incomeTab" Title="Доход" Icon="icon_income.png" ContentTemplate="{DataTemplate local:OperationPage}"
Shell.BackgroundColor="{StaticResource Income}" Shell.TabBarBackgroundColor="{StaticResource Income}"/>
<ShellContent x:Name="statisticsTab" Title="Статистика" Icon="icon_statistics.png" ContentTemplate="{DataTemplate local:StatisticsPage}" />
<ShellContent x:Name="historyTab" Title="История" Icon="icon_history.png" ContentTemplate="{DataTemplate local:HistoryPage}" />
</TabBar>
</Shell>
型
谢谢大家的意见和建议
我试图在文档中找到一些关于这个问题的东西,但没有找到关于将一些数据从一个页面发送到另一个页面的文章或任何合适的解决方案
1条答案
按热度按时间hmae6n7t1#
您可以使用
BindableProperty
来实现这一点。您可以尝试在内容页面(OperationPage.xaml.cs
)中添加一个可绑定的属性,并将数据传递到页面OperationPage
。请参考以下代码:
字符串
然后在
AppShell.xaml
中,您可以向OperationPage
传递一些特殊值,如下所示:型