Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# My Ink Manager用户控件可以保存签名,但不能通过应用程序栏的“保存”按钮保存签名_C#_Xaml_Winrt Xaml - Fatal编程技术网

C# My Ink Manager用户控件可以保存签名,但不能通过应用程序栏的“保存”按钮保存签名

C# My Ink Manager用户控件可以保存签名,但不能通过应用程序栏的“保存”按钮保存签名,c#,xaml,winrt-xaml,C#,Xaml,Winrt Xaml,我是新赢得RT的,所以我使用MSDN引用作为我的签名控件,请参阅 在这段代码中,我可以通过用户控件中的保存按钮保存签名。但我想通过应用程序栏中的“保存”按钮保存签名,不在用户控制范围内。 问题是,我无法解决如何将带有canvass控件的用户控件绑定到保存签名所需的视图模型。 在我的ViewModel中,我使用Prism保存数据 public SurveyPageViewModel(INavigationService navigationService, ISurveyRepository su

我是新赢得RT的,所以我使用MSDN引用作为我的签名控件,请参阅 在这段代码中,我可以通过用户控件中的保存按钮保存签名。但我想通过应用程序栏中的“保存”按钮保存签名,不在用户控制范围内。 问题是,我无法解决如何将带有canvass控件的用户控件绑定到保存签名所需的视图模型。 在我的ViewModel中,我使用Prism保存数据

public SurveyPageViewModel(INavigationService navigationService, ISurveyRepository surveyRepository, ILoggedOnUser loggedOnUser, IEventAggregator eventAggregator, IAppdispatcher appdispatcher, IAppState state)
{
    NavService = navigationService;
    SurvRepository = surveyRepository;
    CurrentLoggedOnUser = loggedOnUser;
    EventAgg = eventAggregator;
    AppDis = appdispatcher;
    State = state;

    CancelExitCommand = new DelegateCommand(DoCancelExit);
    SaveAndExitCommand = new DelegateCommand(DoSaveAndExit);
    SaveCommand = new DelegateCommand(DoSave);
}
在DoSave方法中,我尝试保存签名

case AppQuestionType.Signature:
    var sign = this.Signature;
    sign.JobId = propertySurveyId;
    if (!string.IsNullOrEmpty(SignatureFullNameOfPerson))
    {
        SurveyPageViewModel spPageViewModel;
        //var surveyRepository = M.Survey.UILogic.Repositoriesolve(typeof(ISurveyRepository)) as ISurveyRepository;
        //spPageViewModel.AddSignatureFileEntry(propertySurveyId, 
        //this.SignatureFilename,
        //this.SignatureFullNameOfPerson);
    }
(注释掉的代码是我不起作用的尝试)

用户控件如下所示:

<UserControl
    x:Class="M.Survey.UserControls.SignUserControl1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:M.Survey.UserControls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" 
    xmlns:templateSelectors="using:M.Survey.TemplateSelectors"
    xmlns:converters="using:M.Survey.Converters" 
    xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"
    xmlns:viewModels="using:M.Survey.UILogic.ViewModels" Width="348">

    <UserControl.Resources>

        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Themes/Styles.xaml" />
                <ResourceDictionary Source="/Themes/AllQuestionDataTemplates.xaml" />
                <ResourceDictionary Source="/Themes/DataTemplates.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
            <converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
            <converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" />

            <templateSelectors:QuestionTemplateSelector x:Key="QuestionDisplay" Signature="{StaticResource Signature}" />
        </ResourceDictionary>

    </UserControl.Resources>
    <Grid >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="95*"/>
            <ColumnDefinition Width="79*"/>
        </Grid.ColumnDefinitions>

        <TextBox HorizontalAlignment="Left" Margin="54,21,0,247" TextWrapping="Wrap" Text="{Binding SignatureFullNameOfPerson, Mode=TwoWay}" Width="273" RequestedTheme="Dark" Grid.ColumnSpan="2">
            <TextBox.BorderBrush>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="White" Offset="1"/>
                </LinearGradientBrush>
            </TextBox.BorderBrush>
        </TextBox>
        <Grid Margin="41,-9,-32,0" Grid.ColumnSpan="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="154*"/>
                <RowDefinition Height="155*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150*"/>
                <ColumnDefinition Width="157*"/>
                <ColumnDefinition Width="157*"/>
                <ColumnDefinition Width="157*"/>
            </Grid.ColumnDefinitions>
            <StackPanel Name="spHorizontal" Orientation="Horizontal" Margin="31,10,-24,10" Grid.ColumnSpan="2" Grid.RowSpan="2" >
                <viewModels:InkCanvas  
                    x:Name="icSignature"  Width="268" Background="#FF8A8A8A"  Loaded="IcSignature_OnLoaded" Margin="0,98,0,0"  />

            </StackPanel>

            <StackPanel Orientation="Horizontal" Margin="-33,165,65,-74" RenderTransformOrigin="0.5,0.5" Grid.RowSpan="1"  HorizontalAlignment="Right" Width="307" Grid.Row="1" Grid.ColumnSpan="4">
                <Button Content="Erase"      Width="135"  Margin="0,16,3,7" Click="erase_Click" Background="Black" Height="41"/>
                <Button Content="Save"      Width="163"  Margin="0,16,3,7" Background="Black" Click="Save_Click" Height="41" >

                </Button>
                <!--CommandParameter="{Binding ElementName=icSignature}" Command="{Binding SaveSignatureQuestionCommand}"-->
            </StackPanel>
        </Grid>
        <TextBlock HorizontalAlignment="Left" Margin="-140,21,0,0" TextWrapping="Wrap" Text="Name of person" VerticalAlignment="Top" Width="135" Height="48" FontSize="15" Foreground="#FF211C1C"/>
    </Grid>
</UserControl>


非常感谢

您必须通过在xaml上添加用户控件来将其添加到页面中&然后用户控件的数据上下文将成为您的视图模型。希望对你有帮助。非常感谢你的回复。我正在按照你的建议做。但我的问题是画布墨水笔划没有绑定,或者墨水笔划实例没有进入viewmodel。我的目标是在viewmodel中将画布存储为带有墨迹笔划的图像文件。你能建议如何做到这一点吗。非常感谢您必须通过在xaml上添加用户控件来将其添加到页面中&然后用户控件的数据上下文将成为您的视图模型。希望对你有帮助。非常感谢你的回复。我正在按照你的建议做。但我的问题是画布墨水笔划没有绑定,或者墨水笔划实例没有进入viewmodel。我的目标是在viewmodel中将画布存储为带有墨迹笔划的图像文件。你能建议如何做到这一点吗。非常感谢