Is thia you want ?
<Page
x:Class="App2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<local:ButtonEnabledConverter x:Key="buttonenabledconverter"/>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView x:Name="listview" Margin="24">
<ListView.ItemTemplate >
<DataTemplate>
<Grid Background="Blue" Margin="6" >
<Grid.RowDefinitions >
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<TextBox x:Name="textbox" Width="80" Text="{Binding }"/>
<Button Grid.Row="1" Content="Click" IsEnabled="{Binding ElementName=textbox , Path=Text, Converter={StaticResource buttonenabledconverter} }"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Page>
namespace App2
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
List<string> s = new List<string>();
for (int i=0;i <10;i++)
{
s.Add(i.ToString());
}
listview.ItemsSource = s;
}
}
}
namespace App2
{
public class ButtonEnabledConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value!= null)
{
string data = (string)value;
if (data !=string.Empty)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。