fix: binding errors in xaml

This commit is contained in:
leo 2024-06-01 12:13:57 +08:00
parent b74bd997fe
commit 1257234712
10 changed files with 38 additions and 39 deletions

View file

@ -362,7 +362,7 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Width="12" Width="12"
Fill="{Binding $parent.Foreground}"/> Fill="{DynamicResource Brush.FG1}"/>
</ToggleButton> </ToggleButton>
<ToggleButton Theme="{StaticResource SearchPanelTextBoxButton}" <ToggleButton Theme="{StaticResource SearchPanelTextBoxButton}"
IsChecked="{Binding $parent[aes:SearchPanel].WholeWords, Mode=TwoWay}" IsChecked="{Binding $parent[aes:SearchPanel].WholeWords, Mode=TwoWay}"
@ -374,7 +374,7 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Width="14" Width="14"
Fill="{Binding $parent.Foreground}"/> Fill="{DynamicResource Brush.FG1}"/>
</ToggleButton> </ToggleButton>
<ToggleButton Theme="{StaticResource SearchPanelTextBoxButton}" <ToggleButton Theme="{StaticResource SearchPanelTextBoxButton}"
IsChecked="{Binding $parent[aes:SearchPanel].UseRegex, Mode=TwoWay}" IsChecked="{Binding $parent[aes:SearchPanel].UseRegex, Mode=TwoWay}"
@ -386,7 +386,7 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Width="12" Width="12"
Fill="{Binding $parent.Foreground}"/> Fill="{DynamicResource Brush.FG1}"/>
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
</TextBox.InnerRightContent> </TextBox.InnerRightContent>

View file

@ -11,9 +11,9 @@ namespace SourceGit.Views
public partial class ChangeCollectionView : UserControl public partial class ChangeCollectionView : UserControl
{ {
public static readonly StyledProperty<bool> IsWorkingCopyChangeProperty = public static readonly StyledProperty<bool> IsWorkingCopyChangeProperty =
AvaloniaProperty.Register<ChangeCollectionView, bool>(nameof(IsWorkingCopy), false); AvaloniaProperty.Register<ChangeCollectionView, bool>(nameof(IsWorkingCopyChange), false);
public bool IsWorkingCopy public bool IsWorkingCopyChange
{ {
get => GetValue(IsWorkingCopyChangeProperty); get => GetValue(IsWorkingCopyChangeProperty);
set => SetValue(IsWorkingCopyChangeProperty, value); set => SetValue(IsWorkingCopyChangeProperty, value);

View file

@ -2,7 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels" xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views" xmlns:v="using:SourceGit.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
@ -11,14 +10,14 @@
<StackPanel Orientation="Vertical" Margin="8,0,0,0"> <StackPanel Orientation="Vertical" Margin="8,0,0,0">
<TextBlock Classes="bold" FontSize="18" Text="{DynamicResource Text.Clone}"/> <TextBlock Classes="bold" FontSize="18" Text="{DynamicResource Text.Clone}"/>
<Grid Margin="8,16,0,0" Height="28" ColumnDefinitions="120,*"> <Grid Margin="8,16,0,0" Height="28" ColumnDefinitions="140,*">
<TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.Clone.RemoteURL}"/> <TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.Clone.RemoteURL}"/>
<TextBox Grid.Column="1" CornerRadius="3" Text="{Binding Remote, Mode=TwoWay}" v:AutoFocusBehaviour.IsEnabled="True"/> <TextBox Grid.Column="1" CornerRadius="3" Text="{Binding Remote, Mode=TwoWay}" v:AutoFocusBehaviour.IsEnabled="True"/>
</Grid> </Grid>
<Grid Margin="8,4,0,0" Height="28" ColumnDefinitions="120,*" IsVisible="{Binding UseSSH}"> <Grid Margin="8,4,0,0" Height="28" ColumnDefinitions="140,*" IsVisible="{Binding UseSSH}">
<TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.SSHKey}"/> <TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.SSHKey}"/>
<TextBox Grid.Column="1" <TextBox Grid.Column="1"
x:Name="txtSSHKey" x:Name="TxtSshKey"
Height="28" Height="28"
CornerRadius="3" CornerRadius="3"
Watermark="{DynamicResource Text.SSHKey.Placeholder}" Watermark="{DynamicResource Text.SSHKey.Placeholder}"
@ -30,10 +29,10 @@
</TextBox.InnerRightContent> </TextBox.InnerRightContent>
</TextBox> </TextBox>
</Grid> </Grid>
<Grid Margin="8,4,0,0" Height="28" ColumnDefinitions="120,*"> <Grid Margin="8,4,0,0" Height="28" ColumnDefinitions="140,*">
<TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.Clone.ParentFolder}"/> <TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.Clone.ParentFolder}"/>
<TextBox Grid.Column="1" <TextBox Grid.Column="1"
x:Name="txtParentFolder" x:Name="TxtParentFolder"
Height="28" Height="28"
CornerRadius="3" CornerRadius="3"
Text="{Binding ParentFolder, Mode=TwoWay}"> Text="{Binding ParentFolder, Mode=TwoWay}">
@ -44,11 +43,11 @@
</TextBox.InnerRightContent> </TextBox.InnerRightContent>
</TextBox> </TextBox>
</Grid> </Grid>
<Grid Margin="8,4,0,0" Height="28" ColumnDefinitions="120,*"> <Grid Margin="8,4,0,0" Height="28" ColumnDefinitions="140,*">
<TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.Clone.LocalName}"/> <TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.Clone.LocalName}"/>
<TextBox Grid.Column="1" CornerRadius="3" Watermark="{DynamicResource Text.Clone.LocalName.Placeholder}" Text="{Binding Local, Mode=TwoWay}"/> <TextBox Grid.Column="1" CornerRadius="3" Watermark="{DynamicResource Text.Clone.LocalName.Placeholder}" Text="{Binding Local, Mode=TwoWay}"/>
</Grid> </Grid>
<Grid Margin="8,4,0,0" Height="28" ColumnDefinitions="120,*"> <Grid Margin="8,4,0,0" Height="28" ColumnDefinitions="140,*">
<TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.Clone.AdditionalParam}"/> <TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.Clone.AdditionalParam}"/>
<TextBox Grid.Column="1" CornerRadius="3" Watermark="{DynamicResource Text.Clone.AdditionalParam.Placeholder}" Text="{Binding ExtraArgs, Mode=TwoWay}"/> <TextBox Grid.Column="1" CornerRadius="3" Watermark="{DynamicResource Text.Clone.AdditionalParam.Placeholder}" Text="{Binding ExtraArgs, Mode=TwoWay}"/>
</Grid> </Grid>

View file

@ -15,11 +15,12 @@ namespace SourceGit.Views
{ {
var options = new FolderPickerOpenOptions() { AllowMultiple = false }; var options = new FolderPickerOpenOptions() { AllowMultiple = false };
var toplevel = TopLevel.GetTopLevel(this); var toplevel = TopLevel.GetTopLevel(this);
if (toplevel == null)
return;
var selected = await toplevel.StorageProvider.OpenFolderPickerAsync(options); var selected = await toplevel.StorageProvider.OpenFolderPickerAsync(options);
if (selected.Count == 1) if (selected.Count == 1)
{ TxtParentFolder.Text = selected[0].Path.LocalPath;
txtParentFolder.Text = selected[0].Path.LocalPath;
}
e.Handled = true; e.Handled = true;
} }
@ -28,11 +29,12 @@ namespace SourceGit.Views
{ {
var options = new FilePickerOpenOptions() { AllowMultiple = false, FileTypeFilter = [new FilePickerFileType("SSHKey") { Patterns = ["*.*"] }] }; var options = new FilePickerOpenOptions() { AllowMultiple = false, FileTypeFilter = [new FilePickerFileType("SSHKey") { Patterns = ["*.*"] }] };
var toplevel = TopLevel.GetTopLevel(this); var toplevel = TopLevel.GetTopLevel(this);
if (toplevel == null)
return;
var selected = await toplevel.StorageProvider.OpenFilePickerAsync(options); var selected = await toplevel.StorageProvider.OpenFilePickerAsync(options);
if (selected.Count == 1) if (selected.Count == 1)
{ TxtSshKey.Text = selected[0].Path.LocalPath;
txtSSHKey.Text = selected[0].Path.LocalPath;
}
e.Handled = true; e.Handled = true;
} }

View file

@ -46,7 +46,7 @@
<!-- Changes --> <!-- Changes -->
<Border Grid.Row="1" Margin="0,4,0,0" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" Background="{DynamicResource Brush.Contents}"> <Border Grid.Row="1" Margin="0,4,0,0" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" Background="{DynamicResource Brush.Contents}">
<v:ChangeCollectionView IsWorkingCopy="False" <v:ChangeCollectionView IsWorkingCopyChange="False"
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=CommitChangeViewMode}" ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=CommitChangeViewMode}"
Changes="{Binding VisibleChanges}" Changes="{Binding VisibleChanges}"
SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}" SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}"

View file

@ -34,7 +34,7 @@
Text="{DynamicResource Text.CommitDetail.Changes}"/> Text="{DynamicResource Text.CommitDetail.Changes}"/>
<v:ChangeCollectionView Grid.Column="1" <v:ChangeCollectionView Grid.Column="1"
IsWorkingCopy="False" IsWorkingCopyChange="False"
Margin="8,0,0,0" Margin="8,0,0,0"
ViewMode="List" ViewMode="List"
Changes="{Binding Changes}" Changes="{Binding Changes}"

View file

@ -121,14 +121,14 @@
<Border.ContextMenu> <Border.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="{DynamicResource Text.PageTabBar.Tab.Close}" <MenuItem Header="{DynamicResource Text.PageTabBar.Tab.Close}"
Command="{Binding #me.DataContext.(vm:Launcher).CloseTab}" Command="{Binding #me.((vm:Launcher)DataContext).CloseTab}"
CommandParameter="{Binding}" CommandParameter="{Binding}"
InputGesture="{OnPlatform Ctrl+W, macOS=⌘+W}"/> InputGesture="{OnPlatform Ctrl+W, macOS=⌘+W}"/>
<MenuItem Header="{DynamicResource Text.PageTabBar.Tab.CloseOther}" <MenuItem Header="{DynamicResource Text.PageTabBar.Tab.CloseOther}"
Command="{Binding #me.DataContext.(vm:Launcher).CloseOtherTabs}" Command="{Binding #me.((vm:Launcher)DataContext).CloseOtherTabs}"
CommandParameter="{Binding}"/> CommandParameter="{Binding}"/>
<MenuItem Header="{DynamicResource Text.PageTabBar.Tab.CloseRight}" <MenuItem Header="{DynamicResource Text.PageTabBar.Tab.CloseRight}"
Command="{Binding #me.DataContext.(vm:Launcher).CloseRightTabs}" Command="{Binding #me.((vm:Launcher)DataContext).CloseRightTabs}"
CommandParameter="{Binding}"/> CommandParameter="{Binding}"/>
<MenuItem Header="-" IsVisible="{Binding Node.IsRepository}"/> <MenuItem Header="-" IsVisible="{Binding Node.IsRepository}"/>
<MenuItem IsVisible="{Binding Node.IsRepository}"> <MenuItem IsVisible="{Binding Node.IsRepository}">
@ -200,7 +200,7 @@
<Button Grid.Column="2" <Button Grid.Column="2"
Classes="icon_button" Classes="icon_button"
Width="16" Height="16" Margin="12,0" Width="16" Height="16" Margin="12,0"
Command="{Binding #me.DataContext.(vm:Launcher).CloseTab}" Command="{Binding #me.((vm:Launcher)DataContext).CloseTab}"
CommandParameter="{Binding}"> CommandParameter="{Binding}">
<ToolTip.Tip> <ToolTip.Tip>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
@ -215,7 +215,7 @@
<MultiBinding Converter="{x:Static c:LauncherPageConverters.ToTabSeperatorVisible}"> <MultiBinding Converter="{x:Static c:LauncherPageConverters.ToTabSeperatorVisible}">
<Binding/> <Binding/>
<Binding Path="$parent[ListBox].SelectedItem"/> <Binding Path="$parent[ListBox].SelectedItem"/>
<Binding Path="#me.DataContext.(vm:Launcher).Pages"/> <Binding Path="#me.((vm:Launcher)DataContext).Pages"/>
</MultiBinding> </MultiBinding>
</Rectangle.IsVisible> </Rectangle.IsVisible>
</Rectangle> </Rectangle>
@ -285,8 +285,8 @@
</Border.BorderThickness> </Border.BorderThickness>
<Border.Effect> <Border.Effect>
<OnPlatform> <OnPlatform Default="{x:Null}">
<On Options="Windows, macOS"> <On Options="macOS, Windows">
<DropShadowEffect BlurRadius="8" OffsetX="0" OffsetY="0" Color="Black" Opacity=".5"/> <DropShadowEffect BlurRadius="8" OffsetX="0" OffsetY="0" Color="Black" Opacity=".5"/>
</On> </On>
</OnPlatform> </OnPlatform>
@ -356,11 +356,11 @@
Margin="8" Padding="0" Margin="8" Padding="0"
VerticalContentAlignment="Top" VerticalContentAlignment="Top"
Text="{Binding Message}"/> Text="{Binding Message}"/>
<Button Grid.Row="3" <Button Grid.Row="2"
Classes="flat primary" Classes="flat primary"
Height="30" Height="30"
Margin="4,0" Margin="4,0"
Command="{Binding #me.DataContext.(vm:Launcher).ActivePage.DismissNotification}" Command="{Binding #me.((vm:Launcher)DataContext).ActivePage.DismissNotification}"
CommandParameter="{Binding}" CommandParameter="{Binding}"
Content="{DynamicResource Text.Close}" Content="{DynamicResource Text.Close}"
HorizontalAlignment="Right" HorizontalAlignment="Right"

View file

@ -103,7 +103,7 @@
<!-- Changes --> <!-- Changes -->
<Border Grid.Row="1" Margin="0,4,0,0" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" Background="{DynamicResource Brush.Contents}"> <Border Grid.Row="1" Margin="0,4,0,0" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" Background="{DynamicResource Brush.Contents}">
<v:ChangeCollectionView IsWorkingCopy="False" <v:ChangeCollectionView IsWorkingCopyChange="False"
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=CommitChangeViewMode}" ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=CommitChangeViewMode}"
Changes="{Binding VisibleChanges}" Changes="{Binding VisibleChanges}"
SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}" SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}"

View file

@ -5,7 +5,6 @@
xmlns:m="using:SourceGit.Models" xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels" xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views" xmlns:v="using:SourceGit.Views"
xmlns:c="using:SourceGit.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.TextDiffView" x:Class="SourceGit.Views.TextDiffView"
Background="{DynamicResource Brush.Contents}"> Background="{DynamicResource Brush.Contents}">
@ -19,14 +18,14 @@
SecondaryFG="{DynamicResource Brush.FG2}" SecondaryFG="{DynamicResource Brush.FG2}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
DiffData="{Binding}" DiffData="{Binding}"
SyncScrollOffset="{Binding $parent[v:DiffView].DataContext.(vm:DiffContext).SyncScrollOffset, Mode=TwoWay}" SyncScrollOffset="{Binding $parent[v:DiffView].((vm:DiffContext)DataContext).SyncScrollOffset, Mode=TwoWay}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting, Mode=TwoWay}"/> UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting, Mode=TwoWay}"/>
</DataTemplate> </DataTemplate>
<DataTemplate DataType="vm:TwoSideTextDiff"> <DataTemplate DataType="vm:TwoSideTextDiff">
<Grid ColumnDefinitions="*,1,*"> <Grid ColumnDefinitions="*,1,*">
<v:SingleSideTextDiffPresenter Grid.Column="0" <v:SingleSideTextDiffPresenter Grid.Column="0"
SyncScrollOffset="{Binding $parent[v:DiffView].DataContext.(vm:DiffContext).SyncScrollOffset, Mode=TwoWay}" SyncScrollOffset="{Binding $parent[v:DiffView].((vm:DiffContext)DataContext).SyncScrollOffset, Mode=TwoWay}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting, Mode=TwoWay}" UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting, Mode=TwoWay}"
IsOld="True" IsOld="True"
HorizontalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
@ -41,7 +40,7 @@
<Rectangle Grid.Column="1" Fill="{DynamicResource Brush.Border2}" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch"/> <Rectangle Grid.Column="1" Fill="{DynamicResource Brush.Border2}" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
<v:SingleSideTextDiffPresenter Grid.Column="2" <v:SingleSideTextDiffPresenter Grid.Column="2"
SyncScrollOffset="{Binding $parent[v:DiffView].DataContext.(vm:DiffContext).SyncScrollOffset, Mode=TwoWay}" SyncScrollOffset="{Binding $parent[v:DiffView].((vm:DiffContext)DataContext).SyncScrollOffset, Mode=TwoWay}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting, Mode=TwoWay}" UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting, Mode=TwoWay}"
IsOld="False" IsOld="False"
HorizontalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"

View file

@ -2,7 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels" xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views" xmlns:v="using:SourceGit.Views"
xmlns:c="using:SourceGit.Converters" xmlns:c="using:SourceGit.Converters"
@ -38,7 +37,7 @@
Classes="toggle_untracked" Classes="toggle_untracked"
Width="26" Height="14" Width="26" Height="14"
ToolTip.Tip="{DynamicResource Text.WorkingCopy.IncludeUntracked}" ToolTip.Tip="{DynamicResource Text.WorkingCopy.IncludeUntracked}"
IsChecked="{Binding $parent[v:Repository].DataContext.(vm:Repository).IncludeUntracked, Mode=TwoWay}"/> IsChecked="{Binding IncludeUntracked, Mode=TwoWay}"/>
<Button Grid.Column="7" <Button Grid.Column="7"
Classes="icon_button" Classes="icon_button"
Width="26" Height="14" Width="26" Height="14"
@ -65,7 +64,7 @@
<!-- Unstaged Changes --> <!-- Unstaged Changes -->
<v:ChangeCollectionView Grid.Row="1" <v:ChangeCollectionView Grid.Row="1"
IsWorkingCopy="True" IsWorkingCopyChange="True"
SingleSelect="False" SingleSelect="False"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=UnstagedChangeViewMode}" ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=UnstagedChangeViewMode}"
@ -99,7 +98,7 @@
<!-- Staged Changes --> <!-- Staged Changes -->
<v:ChangeCollectionView Grid.Row="3" <v:ChangeCollectionView Grid.Row="3"
IsWorkingCopy="False" IsWorkingCopyChange="False"
SingleSelect="False" SingleSelect="False"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=StagedChangeViewMode}" ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=StagedChangeViewMode}"