我的问题是事件。在 AppBar 中,我发明的所有事件都没有起作用。(MessageDialog 或其他事件),当 AppBar 显示时,我无法隐藏,并且在 AppBar 中没有点击按钮。
<Page.BottomAppBar>
<AppBar x:Name="AppBar" Background="#FF1DB05F">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button x:Name="SaveButton" Style="{StaticResource AppBarButtonStyle}"
Content=""
AutomationProperties.Name="Save" >
<WinRtBehaviors:Interaction.Behaviors>
<Win8nl_Behavior:EventToCommandBehavior Event="Tapped"
Command="NewFileXml"
/>
</WinRtBehaviors:Interaction.Behaviors>
</Button>
在 MainViewModel.cs
public async void NewFileXml()
{
XmlDocument dom = new XmlDocument();
XmlComment comment = dom.CreateComment("This is Goal a Year");
XmlElement x;
dom.AppendChild(comment);
x = dom.CreateElement("Goal of a Year");
dom.AppendChild(x);
XmlElement stepXml = dom.CreateElement("Goalyear");
XmlElement goalYearXml = dom.CreateElement("GoalStep");
stepXml.InnerText = GoalYear;
goalYearXml.AppendChild(stepXml);
Windows.Storage.StorageFolder sf = await Windows.ApplicationModel.Package.Current.InstalledLocation.CreateFolderAsync("GoalPlan");
StorageFile st = await sf.CreateFileAsync("GoalYear.xml");
await dom.SaveToFileAsync(st);
}
public ICommand NewFile
{
get
{
return new RelayCommand(() =>
{
NewFileXml();
});
}
}
我在波兰微软的帮助下做到了。也许有人要添加。
private RelayCommand exampleContent;
public RelayCommand ItIsBind
{
get
{
return exampleContent ?? (exampleContent = new RelayCommand(ContentLoad));
}
}
**Method example**
public void ContentLoad()
{
}