i have used a RadTileView,
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
x:Class="DemoShow.usercontrol.UserControl1"
mc:Ignorable="d" >
<UserControl.Resources>
<Style x:Key="TextBoxThumb" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="true">
<Setter Property="BorderThickness" Value="1,1,1,1" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="BorderThickness" Value="0,0,0,0"/>
</Trigger>
</Style.Triggers>
</Style>
<DataTemplate x:Key="headerTemplate">
<TextBlock Text="{Binding Number}" />
</DataTemplate>
<DataTemplate x:Key="contentTemplate">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding Name,Mode=TwoWay}" />
<TextBox Grid.Row="1" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding Birthday,Mode=TwoWay}" />
<TextBox Grid.Row="2" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding age,Mode=TwoWay}" />
<TextBox Grid.Row="3" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding Sex,Mode=TwoWay}" />
<TextBox Grid.Row="4" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding CheckType,Mode=TwoWay}" />
<TextBox Grid.Row="5" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding Time,Mode=TwoWay}" />
<Button Grid.Row="5" Content="123" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{Binding DataContext.LoginCommand,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}, AncestorLevel=1}}"
CommandParameter="{Binding Name}"
/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid>
<telerik:RadTileView
IsAutoScrollingEnabled="True"
IsDockingEnabled="True"
IsVirtualizing="True"
ColumnsCount="2"
RowHeight="200"
ColumnWidth="300"
MinimizedColumnWidth="300"
MinimizedRowHeight="200"
MinimizedItemsPosition="Bottom"
ContentTemplate="{StaticResource contentTemplate}"
ItemsSource="{Binding Path=Items,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemTemplate="{StaticResource headerTemplate}"
PreservePositionWhenMaximized="False"
TileStateChangeTrigger="SingleClick">
</telerik:RadTileView>
</Grid>
</UserControl>
i change the BindingList<People>
public class MainViewModel : ViewModelBase
{
private BindingList<People> items;
private BindingList<People> itemstem;
public ICommand LoginCommand
{
get
{
return new RelayCommand<object>(
(parameter) =>
{
ChangeInputEnable(parameter);
}
);
}
}
ui not update public class People
{
public string Name { get; set; }
public string Birthday { get; set;}
public string age { get; set; }
public string Sex { get; set; }
public string CheckType { get; set; }
public string Time { get; set; }
public string Number { get; set; }
public bool ShowFlag { get; set; }
}
private void ChangeInputEnable(object parameter)
{
//string str = parameter.ToString();
//var obj = items.FirstOrDefault(x => x.Name == str);
//int n = items.IndexOf(obj);
//MessageBox.Show(items[n].ShowFlag.ToString());
//if (obj != null)
//{
// if (obj.ShowFlag) obj.ShowFlag = false;
// else obj.ShowFlag = true;
// RaisePropertyChanged("ShowFlag");
// RaisePropertyChanged("Items");
// MessageBox.Show(items[n].ShowFlag.ToString());
// MessageBox.Show(str);
//}
string str = parameter.ToString();
var obj = items.FirstOrDefault(x => x.Name == str);
int n = items.IndexOf(obj);
if (obj != null)
{
if (obj.ShowFlag) obj.ShowFlag = false;
else obj.ShowFlag = true;
obj.Name += "tttt";
items.ListChanged += (o, e) => RaisePropertyChanged(("Items"));
itemstem = items;
items = null;
items = itemstem;
RaisePropertyChanged("Name");
RaisePropertyChanged("Items");
}
//items.Add(new People()
//{
// Birthday = "1985-08-08",
// age = "38",
// Sex = "Male",
// CheckType = "PET-CT",
// Time = "10:30",
// Name = "tttt",
// Number = "10"
//});
//RaisePropertyChanged("Items");
}
public MainViewModel()
{
List<People> itemsSource = new List<People>();
for (int i = 0; i < 5; i++)
{
itemsSource.Add(new People()
{
Birthday = "1985-08-08",
age = "38",
Sex = "Male",
CheckType = "PET-CT",
Time = "10:30",
Name = this.names[i % 12],
Number = i.ToString(),
ShowFlag =true
});
}
this.items = new BindingList<People>(itemsSource);
}
public BindingList<People> Items
{
get
{
return this.items;
}
set
{
this.items =value;
RaisePropertyChanged("Items");
}
}
private List<string> names = new List<string>
{
"Andrew Fuller",
"Martin Sommer",
"Anne Dogsworth",
"Steven Buchanan",
"Janet Leverling",
"Michael Suyama",
"Margaret Peacock",
"Robert King",
"John Steel",
"Laura Gallahan",
"Nancy Davolio",
"Ann Devon"
};
}
can you help me ?
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
x:Class="DemoShow.usercontrol.UserControl1"
mc:Ignorable="d" >
<UserControl.Resources>
<Style x:Key="TextBoxThumb" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="true">
<Setter Property="BorderThickness" Value="1,1,1,1" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="BorderThickness" Value="0,0,0,0"/>
</Trigger>
</Style.Triggers>
</Style>
<DataTemplate x:Key="headerTemplate">
<TextBlock Text="{Binding Number}" />
</DataTemplate>
<DataTemplate x:Key="contentTemplate">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding Name,Mode=TwoWay}" />
<TextBox Grid.Row="1" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding Birthday,Mode=TwoWay}" />
<TextBox Grid.Row="2" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding age,Mode=TwoWay}" />
<TextBox Grid.Row="3" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding Sex,Mode=TwoWay}" />
<TextBox Grid.Row="4" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding CheckType,Mode=TwoWay}" />
<TextBox Grid.Row="5" Style="{StaticResource TextBoxThumb}" IsEnabled="{Binding Path=ShowFlag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Text="{Binding Time,Mode=TwoWay}" />
<Button Grid.Row="5" Content="123" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{Binding DataContext.LoginCommand,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}, AncestorLevel=1}}"
CommandParameter="{Binding Name}"
/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid>
<telerik:RadTileView
IsAutoScrollingEnabled="True"
IsDockingEnabled="True"
IsVirtualizing="True"
ColumnsCount="2"
RowHeight="200"
ColumnWidth="300"
MinimizedColumnWidth="300"
MinimizedRowHeight="200"
MinimizedItemsPosition="Bottom"
ContentTemplate="{StaticResource contentTemplate}"
ItemsSource="{Binding Path=Items,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemTemplate="{StaticResource headerTemplate}"
PreservePositionWhenMaximized="False"
TileStateChangeTrigger="SingleClick">
</telerik:RadTileView>
</Grid>
</UserControl>
public class MainViewModel : ViewModelBase
{
private BindingList<People> items;
private BindingList<People> itemstem;
public ICommand LoginCommand
{
get
{
return new RelayCommand<object>(
(parameter) =>
{
ChangeInputEnable(parameter);
}
);
}
}
ui not update public class People
{
public string Name { get; set; }
public string Birthday { get; set;}
public string age { get; set; }
public string Sex { get; set; }
public string CheckType { get; set; }
public string Time { get; set; }
public string Number { get; set; }
public bool ShowFlag { get; set; }
}
private void ChangeInputEnable(object parameter)
{
//string str = parameter.ToString();
//var obj = items.FirstOrDefault(x => x.Name == str);
//int n = items.IndexOf(obj);
//MessageBox.Show(items[n].ShowFlag.ToString());
//if (obj != null)
//{
// if (obj.ShowFlag) obj.ShowFlag = false;
// else obj.ShowFlag = true;
// RaisePropertyChanged("ShowFlag");
// RaisePropertyChanged("Items");
// MessageBox.Show(items[n].ShowFlag.ToString());
// MessageBox.Show(str);
//}
string str = parameter.ToString();
var obj = items.FirstOrDefault(x => x.Name == str);
int n = items.IndexOf(obj);
if (obj != null)
{
if (obj.ShowFlag) obj.ShowFlag = false;
else obj.ShowFlag = true;
obj.Name += "tttt";
items.ListChanged += (o, e) => RaisePropertyChanged(("Items"));
itemstem = items;
items = null;
items = itemstem;
RaisePropertyChanged("Name");
RaisePropertyChanged("Items");
}
//items.Add(new People()
//{
// Birthday = "1985-08-08",
// age = "38",
// Sex = "Male",
// CheckType = "PET-CT",
// Time = "10:30",
// Name = "tttt",
// Number = "10"
//});
//RaisePropertyChanged("Items");
}
public MainViewModel()
{
List<People> itemsSource = new List<People>();
for (int i = 0; i < 5; i++)
{
itemsSource.Add(new People()
{
Birthday = "1985-08-08",
age = "38",
Sex = "Male",
CheckType = "PET-CT",
Time = "10:30",
Name = this.names[i % 12],
Number = i.ToString(),
ShowFlag =true
});
}
this.items = new BindingList<People>(itemsSource);
}
public BindingList<People> Items
{
get
{
return this.items;
}
set
{
this.items =value;
RaisePropertyChanged("Items");
}
}
private List<string> names = new List<string>
{
"Andrew Fuller",
"Martin Sommer",
"Anne Dogsworth",
"Steven Buchanan",
"Janet Leverling",
"Michael Suyama",
"Margaret Peacock",
"Robert King",
"John Steel",
"Laura Gallahan",
"Nancy Davolio",
"Ann Devon"
};
}
can you help me ?