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

View file

@ -11,9 +11,9 @@ namespace SourceGit.Views
public partial class ChangeCollectionView : UserControl
{
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);
set => SetValue(IsWorkingCopyChangeProperty, value);

View file

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

View file

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

View file

@ -46,7 +46,7 @@
<!-- Changes -->
<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}"
Changes="{Binding VisibleChanges}"
SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}"

View file

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

View file

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

View file

@ -103,7 +103,7 @@
<!-- Changes -->
<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}"
Changes="{Binding VisibleChanges}"
SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}"

View file

@ -5,7 +5,6 @@
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views"
xmlns:c="using:SourceGit.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.TextDiffView"
Background="{DynamicResource Brush.Contents}">
@ -19,14 +18,14 @@
SecondaryFG="{DynamicResource Brush.FG2}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
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}"/>
</DataTemplate>
<DataTemplate DataType="vm:TwoSideTextDiff">
<Grid ColumnDefinitions="*,1,*">
<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}"
IsOld="True"
HorizontalScrollBarVisibility="Auto"
@ -41,7 +40,7 @@
<Rectangle Grid.Column="1" Fill="{DynamicResource Brush.Border2}" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
<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}"
IsOld="False"
HorizontalScrollBarVisibility="Auto"

View file

@ -2,7 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views"
xmlns:c="using:SourceGit.Converters"
@ -38,7 +37,7 @@
Classes="toggle_untracked"
Width="26" Height="14"
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"
Classes="icon_button"
Width="26" Height="14"
@ -65,7 +64,7 @@
<!-- Unstaged Changes -->
<v:ChangeCollectionView Grid.Row="1"
IsWorkingCopy="True"
IsWorkingCopyChange="True"
SingleSelect="False"
Background="{DynamicResource Brush.Contents}"
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=UnstagedChangeViewMode}"
@ -99,7 +98,7 @@
<!-- Staged Changes -->
<v:ChangeCollectionView Grid.Row="3"
IsWorkingCopy="False"
IsWorkingCopyChange="False"
SingleSelect="False"
Background="{DynamicResource Brush.Contents}"
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=StagedChangeViewMode}"