내 템플릿 용 프로젝트 마법사를 만들었습니다. 이 마법사를 사용하여 사용자는 앱 이름과 같은 몇 가지 사항을 채우고 앱을 만들 수 있습니다. 문제는 마법사가 시작되지만 마법사를 마친 후 즉시 프로젝트가 생성된다는 것입니다. 이것은 대체가 일어나지 않는다는 것을 의미합니다. 마법사와프로젝트 마법사가 완료되기 전에 프로젝트가 이미 생성되었습니다.
<Window x:Class="PartyTemplateWizard.Form"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="340" d:DesignWidth="750">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="Name" Grid.Column="0" />
<TextBox x:Name="Name" Grid.Column="1" Text="{Binding Path=dummyproperty, FallbackValue='Naam'}" />
<Button Content="Ok" Grid.Column="1" Grid.Row="1" />
</Grid>
</Window>
:
나는 (크게 단순화)이 양식이
public class Wizard : IWizard
{
private readonly Form _form = new Form();
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
try
{
_form.Show();
string name = _form.Name.Text;
if (!string.IsNullOrEmpty(name)) replacementsDictionary.Add("$appname$", name);
}
catch (Exception e)
{
}
}
public bool ShouldAddProjectItem(string filePath)
{
return true;
}
public void RunFinished()
{
}
public void BeforeOpeningFile(ProjectItem projectItem)
{
}
public void ProjectItemFinishedGenerating(ProjectItem projectItem)
{
}
public void ProjectFinishedGenerating(Project project)
{
}
}
을 그리고 코드의이 비트와 내 템플릿이 바인딩 :
<WizardExtension>
<Assembly>PartyTemplateWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=6c4fd97fa2ac3b4f</Assembly>
<FullClassName>PartyTemplateWizard.Wizard</FullClassName>
</WizardExtension>
전체 코드는 github에서 사용할 수 있습니다. https://github.com/Avalaxy/PartyTemplateWizard
마법사가 성공적으로 완료되기 전에 프로젝트가 생성되는 이유를 아는 사람이 있습니까? 아직 Ok 단추에 이벤트 처리기가 없으므로 불가능합니다.
Brilliant! 문제가 완벽하게 해결되었습니다. 이제는 대체물이 제대로 작동합니다. –