我有一个登录页面。
用户登录后,它将重定向到一个页面,其中包含所选城市的文本框。单击它时,将显示城市列表。
我已经使用uwp中的命令编写了onclick事件。登录成功后每次都会调用。我不知道为什么会这样?
我只为onclick事件编写了
<Page
x:Class="IMUMAPP.Views.`enter code here`SectorSelection"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:IMUMAPP.Views"
xmlns:viewmodel="using:IMUMAPP.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:partialViews="using:IMUMAPP.Partial"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
x:Name="Sectors"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid x:Name="LayoutRootSector" Background="Yellow" Margin="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="666*"/>
<RowDefinition Height="100*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!--<Grid Background="Orange" >
<Grid.RowDefinitions>
<RowDefinition Height="12*"/>
<RowDefinition Height="12*"/>
</Grid.RowDefinitions>
<Grid Background="Orange" Grid.Row="1">
<partialViews:Header></partialViews:Header>
</Grid>
</Grid>-->
<Grid Background="Orange" Margin="0,0,0,8.333" >
<Grid.RowDefinitions>
<RowDefinition Height="28*"/>
<RowDefinition Height="25*"/>
</Grid.RowDefinitions>
<Grid Background="Orange" Margin="0,0,0,-0.667" Grid.RowSpan="2" >
<Grid.RowDefinitions>
<RowDefinition Height="12*"/>
<RowDefinition Height="12*"/>
</Grid.RowDefinitions>
<TextBlock Name="HHID" Foreground="Black" FontWeight="Bold" FontSize="12" Margin="0,0,0,26.083" />
<TextBlock x:Name="txtUserName" Foreground="Black" FontWeight="Bold" FontSize="12" Margin="0,23,0,8" Grid.RowSpan="2" />
</Grid>
</Grid>
<Grid Background="Orange" Grid.Row="3" >
<Grid Background="Orange" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left" >
<TextBlock x:Uid="Battery" x:Name="txtBatteryText" Foreground="Black" FontSize="12" FontWeight="Bold" Margin="6,0,0,0"/>
<TextBlock Text=":" Foreground="Black" FontSize="12" FontWeight="Bold" Margin="6,0,0,0" />
<TextBlock x:Name="batteryvalue" Foreground="Black" FontSize="12" FontWeight="Bold" Margin="6,0,0,0" />
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock x:Uid="ZoneFooter" x:Name="txtZoneText" Foreground="Black" FontSize="12" FontWeight="Bold" Margin="0,0,0,0" />
<TextBlock x:Name="txtZones" Text=":" Foreground="Black" FontSize="12" FontWeight="Bold" Margin="6,0,0,0" />
<TextBlock x:Name="zoneVALUE" Foreground="Black" FontSize="12" FontWeight="Bold" Margin="6,0,0,0" />
</StackPanel>
<TextBlock x:Name="txtVersion" Grid.Column="2" HorizontalAlignment="Right" Foreground="Black" FontSize="12" FontWeight="Bold" Margin="0,0,6,0"/>
</Grid>
</Grid>
<!--<Grid Background="Orange" Grid.Row="3" >
<partialViews:Footer></partialViews:Footer>
</Grid>-->
<Grid Grid.Row="1" Margin="0,41.667,0,0" >
<Border BorderThickness="0" BorderBrush="Black" CornerRadius="15,15,15,15" Background="Yellow" Margin="0,0,0,56">
<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" Margin="0,23,0,8.333" >
<StackPanel Orientation="Vertical" Height="527" Width="335">
<StackPanel Width="332" Height="100" HorizontalAlignment="Left" Margin="8,-10,0,0" >
<Grid Height="103">
<Grid.RowDefinitions>
<RowDefinition Height="27*"/>
<RowDefinition Height="77*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="117*"/>
<ColumnDefinition Width="49*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="community" x:Uid="SelectCommunity" FontSize="15" Foreground="Black" TextAlignment="Left" Margin="10,8,38,70" Grid.ColumnSpan="2" Grid.RowSpan="2" />
<TextBlock Text="*" Foreground="Red" Grid.Column="1" TextAlignment="Right" Margin="0,10,38,70" Grid.RowSpan="2"/>
<TextBox Visibility="Collapsed" Text="{Binding _common[0].Community_Name}" Background="Yellow" BorderBrush="#c0c0c0" Foreground="Black" Name="txtcommunity" FontSize="15" Margin="0,10.333,34,0" Grid.Row="1">
</TextBox>
<TextBox Text="{Binding _common[0].Community_Name,Mode=TwoWay}" IsReadOnly="True" Background="Yellow" BorderBrush="#c0c0c0" Foreground="Black" FontSize="13" Margin="10,10.333,38,25" Grid.Row="1" Grid.ColumnSpan="2">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="GotFocus">
<Core:InvokeCommandAction Command="{Binding DataContext.CommunityCmd,ElementName=Sectors,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" CommandParameter="{Binding ElementName=txtcommunity}" ></Core:InvokeCommandAction>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</TextBox>
</Grid>
</StackPanel>
<StackPanel Width="332" Height="100" HorizontalAlignment="Left" Margin="8,0,0,0" >
<Grid Height="103">
<Grid.RowDefinitions>
<RowDefinition Height="27*"/>
<RowDefinition Height="77*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="117*"/>
<ColumnDefinition Width="49*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="sector" x:Uid="SelectSector" FontSize="15" Foreground="Black" TextAlignment="Left" Margin="10,8,38,70" Grid.ColumnSpan="2" Grid.RowSpan="2" />
<TextBlock Text="*" Foreground="Red" Grid.Column="1" TextAlignment="Right" Margin="0,10,38,70" Grid.RowSpan="2"/>
<TextBox Visibility="Collapsed" Text="{Binding _common[0].SectorID}" Background="Yellow" BorderBrush="#c0c0c0" Foreground="Black" Name="txtSectorID" FontSize="15" Margin="0,10.333,34,0" Grid.Row="1">
</TextBox>
<TextBox Text="{Binding _common[0].SectorItem,Mode=TwoWay}" IsReadOnly="True" Background="Yellow" BorderBrush="#c0c0c0" Foreground="Black" Name="txtsrch" FontSize="13" Margin="10,10.333,38,25" Grid.Row="1" Grid.ColumnSpan="2">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="GotFocus">
<Core:InvokeCommandAction Command="{Binding DataContext.SrchCmd,ElementName=Sectors,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" CommandParameter="{Binding ElementName=txtsrch}" ></Core:InvokeCommandAction>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</TextBox>
</Grid>
</StackPanel>
<StackPanel x:Name="stpanel" Width="302" Height="100" HorizontalAlignment="Left" Margin="8,0,0,0" >
<Grid Height="100" Margin="0,0,-37,0" >
<Grid.RowDefinitions>
<RowDefinition Height="30*"/>
<RowDefinition Height="51*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="239"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox Visibility="Collapsed" Text="{Binding _common[0].ZoneID}" Background="Yellow" BorderBrush="#c0c0c0" Foreground="Black" Name="txtZoneID" FontSize="17" Margin="0,10,34,0" Grid.Row="1">
</TextBox>
<TextBlock x:Uid="Zone" x:Name="lblzone" FontSize="15" Foreground="Black" TextAlignment="Left" Margin="10,8,0,0" />
<TextBlock Text="*" Foreground="Red" Grid.Column="1" TextAlignment="Right" Margin="0,10,45,0"/>
<TextBox Text="{Binding _common[0].ZoneItem,Mode=TwoWay}" Loaded="txtzone_Loaded" Background="Yellow" Grid.Row="1" BorderBrush="#c0c0c0" Foreground="Black" IsReadOnly="True" Name="txtzone" FontSize="13" Margin="10,10,45,10" Grid.ColumnSpan="2">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="GotFocus">
<Core:InvokeCommandAction Command="{Binding DataContext.CmdZoneSearch,Mode=TwoWay,ElementName=Sectors, UpdateSourceTrigger=PropertyChanged}" CommandParameter="{Binding ElementName=txtzone}"></Core:InvokeCommandAction>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</TextBox>
<TextBox Visibility="Collapsed" Text="{Binding _common[0].ZoneID}" Background="Yellow" Grid.Row="1" BorderBrush="#c0c0c0" Foreground="Black" Name="txtzoneID" FontSize="17" Margin="0,10,34,0">
</TextBox>
</Grid>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Border>
</Grid>
<StackPanel Grid.Row="2" FlowDirection="LeftToRight" HorizontalAlignment="Stretch" Margin="0,-5,0,0" >
<Grid Height="78" Margin="0,0,0,0" >
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button x:Uid="Back" FontWeight="SemiBold" HorizontalAlignment="Stretch" BorderBrush="White" IsHitTestVisible="True" Grid.Column="0" x:Name="btnBack" Margin="10" Background="#e5e5e5" Foreground="#737373" Height="34">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Tapped">
<Core:InvokeCommandAction Command="{Binding DataContext.CmdBack,Mode=TwoWay,ElementName=Sectors, UpdateSourceTrigger=PropertyChanged}" CommandParameter="{Binding ElementName=btnBack}"></Core:InvokeCommandAction>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</Button>
<Button x:Uid="Countinue" FontWeight="SemiBold" HorizontalAlignment="Stretch" BorderBrush="White" x:Name="NextPage" Background="#e5e5e5" Foreground="#737373" Margin="10" Grid.Column="1" Height="34" >
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Tapped">
<Core:InvokeCommandAction Command="{Binding DataContext.CmdHome,Mode=TwoWay,ElementName=Sectors, UpdateSourceTrigger=PropertyChanged}" CommandParameter="{Binding ElementName=NextPage}"></Core:InvokeCommandAction>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</Button>
</Grid>
</StackPanel>
</Grid>
</Grid>