我有一个from flask import (
Blueprint,
request,
render_template,
flash,
g,
session,
redirect,
url_for
)
from werkzeug import check_password_hash, generate_password_hash
from app import db
from app.authentication.forms import LoginForm, SignupForm
from app.authentication.models import User
mod_auth = Blueprint('auth', __name__, url_prefix='/auth')
@mod_auth.route('/profile')
def profile():
if 'email' not in session:
return redirect(url_for('signin'))
user = User.query.filter_by(email = session['email']).first()
if user is None:
return redirect(url_for('signin'))
else:
return render_template('authentication/profile.html')
@mod_auth.route('/signup/', methods=['GET', 'POST'])
def signup():
form = SignupForm()
if 'email' is session:
return redirect(url_for('profile'))
if request.method == 'POST':
if form.validate() == False:
return render_template("authentication/signup.html", form=form)
else:
new_user = User(form.username.data, form.email.data, form.password.data)
db.session.add(new_user)
db.session.commit()
session['email'] = new_user.email
return "Not found"
elif request.method == 'GET':
return render_template("authentication/signup.html", form=form)
@mod_auth.route('/signin/', methods=['GET', 'POST'])
def signin():
form = LoginForm(request.form)
if form.validate_on_submit():
user = User.query.filter_by(email=form.email.data).first()
if user and check_password_hash(user.password, form.password.data):
session['user_id'] = user.id
flash('Welcome %s' % user.name)
return redirect(url_for('auth.home'))
flash('Wrong email or password', 'error-message')
return render_template("authentication/signin.html", form=form)
,我在那里存储用户添加到集合中的歌曲:
GridView
当<GridView x:Name="MusicGridView" Margin="10" IsItemClickEnabled="True" ItemClick="Play_Song" Grid.Row="0" ItemsSource="{Binding Songs, ElementName=thisPage, Mode=OneWay}" SelectionMode="None">
<GridView.ItemTemplate>
<DataTemplate>
<Grid Height="100" Width="100" RightTapped="Song_RightTapped">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Rectangle Grid.Row="0" Grid.RowSpan="2" Fill="#FF1F4E79"/>
<Image Source="{Binding Path=AlbumArt.Source}" Grid.Row="0" Height="40" Width="40" Margin="10,10,10,0"/>
<TextBlock Text="{Binding Title}" Foreground="White" VerticalAlignment="Bottom" HorizontalAlignment="Center" Grid.Row="1" Margin="5" TextWrapping="Wrap"/>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
被右键点击时(我似乎无法为实际项目设置Grid
属性)我会显示RightTapped
。但是,发件人本身就是PopupMenu
本身,我无法找到实现Grid
的方法,而不会做一些看起来非常奇怪的变通方法。获取GridViewItem
的所选项目不是一个选项,因为未启用选择。有没有一种简单的方法可以将项目作为GridView
?
答案 0 :(得分:0)
如果我正确理解您的问题,您希望获取绑定对象而不是GridView。 如果是这种情况,你可以试试这个。
//input[@value='empty']