I want to make binding betweeen CheckEdit and files txt
string[] path1 = { "Fine.txt", "Debug.txt", "Info.txt" };
I give in data files and output them in a GridControl
I need to do so that you can select specific file
<ItemsControl ItemsSource="{Binding MyCheckBockes}" Margin="0" Grid.Column="1" Grid.RowSpan="1" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<dxe:CheckEdit Content="{Binding}" Padding="2.5" Margin="3" IsChecked="True"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
Concludes Grid
string[] path1 = { "Fine.txt", "Debug.txt", "Info.txt" };
public List<DataText> list;
public TextViewModel()
{
list = ReadTextFile.LoadDateListFromFile(path1);
}
public string[] MyCheckBockes
{
get { return path1; }
set
{
path1 = value;
OnPropertyChange("MyCheckBockes");
}
}
ReadTextFile.LoadDateListFromFile - parsing and out data in GridControl
Question! how to make a binding that you can enable or disable certain data file
You will need to bind to more than just strings. You will have to create some object to hold the enabled information as well. Perhaps something like:
public class MyCheckbox
{
public string FilePath { get; set; }
public bool IsEnabled { get; set; }
}
Then your code would change to:
MyCheckbox[] path1 = {
new MyCheckbox() { FilePath = "Fine.txt", IsEnabled = false },
new MyCheckbox() { FilePath = "Debug.txt", IsEnabled = true },
new MyCheckbox() { FilePath = "Info.txt", IsEnabled = true } };
public MyCheckbox[] MyCheckBockes
{
get { return path1; }
set
{
path1 = value;
OnPropertyChange("MyCheckBockes");
}
}
And your binding:
<dxe:CheckEdit Content="{Binding Path=FilePath}" Padding="2.5" Margin="3" IsChecked="True" IsEnabled="{Binding Path=IsEnabled}"/>