我有一个页面,其中包含一个相对面板,可根据宽度重新组织.但是,除非宽度> 720px,否则它似乎不会在加载时应用任何状态.如果我在加载后调整页面大小,则两个状态都有效.
解决方法是检查加载页面上的窗口大小并手动选择状态,但我相信这应该自动处理?我有其他页面可以工作,我不确定我在做什么不同.这是我的代码的简化版本,我有它设置红色/蓝色背景,所以我可以判断是否/正在应用哪个状态
<Page.Resources>
<converters:HighlightConverter x:Key="HighlightConverter"/>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<gui:MainAppBar x:Name="mainAppBar" Grid.Row="0"/>
<ScrollViewer Grid.Row="1">
<RelativePanel>
<StackPanel x:Name="ZonesContainer" Margin="12,12,0,0">
<TextBlock Text="Zones"/>
<ItemsControl x:Name="ZonesPanel">
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Margin" Value="6"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid x:Name="ZonesWrapGrid" Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="Panel" Orientation="Horizontal">
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
<StackPanel x:Name="SourcesContainer" RelativePanel.RightOf="ZonesContainer" Margin="12,12,0,0">
<GridView x:Name="SourcesPanel" Header="Sources">
</GridView>
</StackPanel>
<StackPanel x:Name="NetworkServicesContainer" RelativePanel.Below="SourcesContainer" RelativePanel.AlignLeftWith="SourcesContainer" Margin="12,12,0,0">
<GridView x:Name="NetworkServicesPanel" Header="Network">
</GridView>
</StackPanel>
</RelativePanel>
</ScrollViewer>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="WindowStates">
<VisualState x:Name="WideState"> …Run Code Online (Sandbox Code Playgroud) 我创建了一个新的xml文档(如果找不到),然后打开它以创建一个新条目.但是,它似乎只是将一个已完成的新XML文件附加到我创建的空白文件的末尾
创作后:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Devices />
Run Code Online (Sandbox Code Playgroud)
添加新的xelement后:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Devices /><?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Devices>
<device>
<name>blah</name>
<src00>True</src00>
</device>
</Devices>
Run Code Online (Sandbox Code Playgroud)
我的代码...我尝试添加两种不同的方式,两者都有相同的结果
// Create file if not found
if (!storage.FileExists("settings\\mydevices.xml"))
{
using (IsolatedStorageFileStream stream = storage.OpenFile("settings\\mydevices.xml", FileMode.Create, FileAccess.ReadWrite))
{
XDocument devicesDoc =
new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("Devices")
);
System.IO.StreamWriter file = new System.IO.StreamWriter(stream);
devicesDoc.Save(file);
file.Dispose();
}
}
// Add new device
using (IsolatedStorageFileStream stream = storage.OpenFile("settings\\mydevices.xml", FileMode.Open, FileAccess.ReadWrite))
{
XDocument mydevicesXml = XDocument.Load(stream);
//XElement …Run Code Online (Sandbox Code Playgroud) 我需要一些帮助编写正则表达式语句来拆分包含一些标签的字符串(不是真正的HTML,我只是使用使用<i>和<b>标签格式化一些文本),并保留分隔符.例如这个字符串:
<b>a bold quote:</b> this is some sample test. How <i>do</i> I do this?
Run Code Online (Sandbox Code Playgroud)
将转变为:
<b>a bold quote:</b>
this is sample text. How
<i>do</i>
I do this?
Run Code Online (Sandbox Code Playgroud)