MainWindow.paml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <Window xmlns="https://github.com/perspex"
  2. xmlns:vm="clr-namespace:BindingTest.ViewModels;assembly=BindingTest"
  3. xmlns:local="clr-namespace:BindingTest;assembly=BindingTest">
  4. <Window.Styles>
  5. <Style Selector="TextBlock.h1">
  6. <Setter Property="FontSize" Value="18"/>
  7. </Style>
  8. </Window.Styles>
  9. <TabControl>
  10. <TabItem Header="Basic">
  11. <StackPanel Orientation="Vertical">
  12. <StackPanel Orientation="Horizontal">
  13. <StackPanel Margin="18" Gap="4" Width="200">
  14. <TextBlock FontSize="16" Text="Simple Bindings"/>
  15. <TextBox Watermark="Two Way" UseFloatingWatermark="True" Text="{Binding Path=StringValue}" Name="first"/>
  16. <TextBox Watermark="One Way" UseFloatingWatermark="True" Text="{Binding Path=StringValue, Mode=OneWay}"/>
  17. <TextBox Watermark="One Time" UseFloatingWatermark="True" Text="{Binding Path=StringValue, Mode=OneTime}"/>
  18. </StackPanel>
  19. <StackPanel Margin="18" Gap="4" Width="200">
  20. <TextBlock FontSize="16" Text="Collection Bindings"/>
  21. <TextBox Watermark="Items[1].StringValue" UseFloatingWatermark="True" Text="{Binding Path=Items[1].StringValue}"/>
  22. <Button Command="{Binding ShuffleItems}">Shuffle</Button>
  23. </StackPanel>
  24. <StackPanel Margin="18" Gap="4" Width="200">
  25. <TextBlock FontSize="16" Text="Negated Bindings"/>
  26. <TextBox Watermark="Boolean String" UseFloatingWatermark="True" Text="{Binding Path=BooleanString}"/>
  27. <CheckBox IsChecked="{Binding !BooleanString}">!BooleanString</CheckBox>
  28. <CheckBox IsChecked="{Binding !!BooleanString}">!!BooleanString</CheckBox>
  29. </StackPanel>
  30. </StackPanel>
  31. <StackPanel Orientation="Horizontal">
  32. <StackPanel Margin="18" Gap="4" Width="200" HorizontalAlignment="Left">
  33. <TextBlock FontSize="16" Text="Numeric Bindings"/>
  34. <TextBox Watermark="Double" UseFloatingWatermark="True" Text="{Binding Path=DoubleValue, Mode=TwoWay}"/>
  35. <TextBlock Text="{Binding Path=DoubleValue}"/>
  36. <ProgressBar Maximum="10" Value="{Binding DoubleValue}"/>
  37. </StackPanel>
  38. <StackPanel Margin="18" Gap="4" Width="200" HorizontalAlignment="Left">
  39. <TextBlock FontSize="16" Text="Binding Sources"/>
  40. <TextBox Watermark="Value of first TextBox" UseFloatingWatermark="True"
  41. Text="{Binding #first.Text, Mode=TwoWay}"/>
  42. </StackPanel>
  43. </StackPanel>
  44. </StackPanel>
  45. </TabItem>
  46. <TabItem Header="ListBox">
  47. <StackPanel Orientation="Horizontal">
  48. <StackPanel.DataTemplates>
  49. <DataTemplate DataType="vm:TestItem">
  50. <TextBlock Text="{Binding StringValue}"/>
  51. </DataTemplate>
  52. </StackPanel.DataTemplates>
  53. <StackPanel Margin="18" Gap="4" Width="200">
  54. <TextBlock FontSize="16" Text="Multiple"/>
  55. <ListBox Items="{Binding Items}" SelectionMode="Multiple" SelectedItems="{Binding SelectedItems}"/>
  56. </StackPanel>
  57. <StackPanel Margin="18" Gap="4" Width="200">
  58. <TextBlock FontSize="16" Text="Multiple"/>
  59. <ListBox Items="{Binding Items}" SelectionMode="Multiple" SelectedItems="{Binding SelectedItems}"/>
  60. </StackPanel>
  61. <ContentControl Content="{Binding SelectedItems[0]}">
  62. <ContentControl.DataTemplates>
  63. <DataTemplate DataType="vm:TestItem">
  64. <local:TestItemView></local:TestItemView>
  65. </DataTemplate>
  66. </ContentControl.DataTemplates>
  67. </ContentControl>
  68. </StackPanel>
  69. </TabItem>
  70. </TabControl>
  71. </Window>