隐藏选择值选择的入口控制 [英] Hiding entry control on selection of picker value

查看:76
本文介绍了隐藏选择值选择的入口控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学习xamarin.forms。我开发了一个简单的应用程序,用于在SQLite中添加Employee



在这个应用程序中有选择器控件(如.Net中的下拉菜单:))。当我在此选择器中选择其他选项时,我想显示/隐藏输入控件(如.net :)中的文本框。)



在.net中我们使用面板显示隐藏控件..类似于我可以在xamarin中使用哪个控件



请注意我已经隐藏并通过使用IsVisible属性显示进入控件..但是隐藏它仍然占用app上的空间页面



我尝试过:



我的Xaml代码



< Picker x:Name =Pkr_DepartmentGrid.Row =13>< / Picker>



<条目x:名称=txtDepartment占位符=输入部门Grid.Row =14IsVisible =False>< / Entry>



我的xaml.cs代码

I am currently learning xamarin.forms. I developed simple application for additon of Employee in SQLite

In this app there is picker control(like dropdown in .Net :)). When i select Other option in this picker i want to show/ hide entry control (like textbox in .net :))

In .net we show hide controls using panel..similarly which control i can use in xamarin

Please note i already hiding and showing entry control by using IsVisible property..but while hiding it still occupies space on app page

What I have tried:

My Xaml code

<Picker x:Name="Pkr_Department" Grid.Row="13" ></Picker>

<Entry x:Name="txtDepartment" Placeholder="Enter Department" Grid.Row="14" IsVisible="False" ></Entry>

My xaml.cs code

Pkr_Department.SelectedIndexChanged += (sender, args) =>
            {
                if (Pkr_Department.SelectedIndex == 0)
                {
                    txtDepartment.IsVisible = true;

                   
                }
                else
                {
                    txtDepartment.IsVisible = false;
                }
            };

推荐答案

你需要把
Grid.Row="14"

身高自动



height Auto

<RowDefinition Height="Auto" />





因此基于IsVisible = True或False高度将自动调整,而Isvisible = False则不会占用空间在页面上。



So based on IsVisible=True or False height will be auto adjust and on Isvisible=False it will not take space on page.


这篇关于隐藏选择值选择的入口控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆