xamarin - 如何在 Xamarin 中使用开关删除标签和条目
问题描述
我正在尝试使用 x:Name="MS" 开关删除标签首付和条目首付,并将条目的文本/值更改为“0”。这是我的 *.xaml 代码
'''
<Label Text="Purchased price"
Margin="0,100,0,0" Padding="13,0,0,0" />
<Entry Placeholder="Price $$"
x:Name="price"
Keyboard="Numeric"
Margin="130,-30,40,0"
Opacity="1" Rotation="0"
TranslationX="16" />
<Label Text="Mortgage ??"
Margin="0,10,0,0" Padding="13,0,0,0"/>
<Switch IsToggled="false"
Margin="130,-30,40,0"
x:Name="MS"/>
<Label Text="Downpayment"
Margin="0,10,0,0" Padding="13,0,0,0"/>
<Entry Placeholder="Down Payment"
x:Name="Downpayment"
Text="DP"
Keyboard="Numeric"
Margin="130,-30,40,0"
Opacity="1" Rotation="0"
TranslationX="16" />
'''
解决方案
Toggled
为事件添加处理程序
<Switch IsToggled="false" Toggled="SwitchToggled" ... />
然后
protected void SwitchToggled(object sender, ToggledEventArgs e)
{
// true if toggled
if (e.Value)
{
Downpayment.IsVisible = false;
DownpaymentLabel.IsVisible = false;
price.Text = "0";
}
}
推荐阅读
- python - 如何在 python 中实现泛型?Java 或 C++ 之类的东西提供
- c# - HttpClient 请求中的错误:对类型“Task<>”的引用声称它是在“System.Runtime”中定义的,但找不到 (CS7069)
- angular - 带有外观='fill'' 的 Mat-Date 在 IE11 和 Edge 中无法正确呈现
- python - 保存 numpy 图像数据集。不增加大小且易于保存和加载数据
- javascript - 如何使用解构来获取参数的目标属性
- python - 无法导入模块“lambda_function”:没有名为“cx_Oracle”的模块
- swift - 为什么在 Data.base64EncodedString 中使用 endLineWithLineFeed 不会在编码字符串的末尾添加新行?
- xpath - 在与 Xpath 保持关系的同时提取信息
- python - model.set_weights(model.get_weights()) 返回错误
- c# - 为什么使等待同步不能在单独的方法中工作?