我正在尝试在UWP上的XAML中访问StaticResource变量的系统命名空间.这是(大部分)我正在使用的:
<Page
x:Class="App.UWP.Views.Step6"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:System="using:System"
mc:Ignorable="d">
<Page.Resources>
<System:Double x:Key="ItemNameWidth">260</System:Double>
</Page.Resources>
<TextBlock FontSize="16" Width="{StaticResource ItemNameWidth}">foo</TextBlock>
</page>
Run Code Online (Sandbox Code Playgroud)
即使<System:Double ...>IntelliSense中的节目有效,我也会遇到以下运行时错误:
类型的异常"Windows.UI.Xaml.Markup.XamlParseException"发生在mscorlib.ni.dll但在用户代码中没有处理
WinRT信息:无法反序列化XBF元数据类型列表,因为在命名空间"System"中找不到"Double".[线:0位置:0]
如果这种方法不起作用,我会对其他声明双重的方式持开放态度.
在我的项目中在Visual Studio中打开XAML页面或用户控件时,IDE将告诉我所有控件都不支持[Control].它也没有向我展示XAML的设计视图.
我已经禁用了所有Visual Studio插件,并且唯一一致的工作是从源代码控制中拉出整个项目并从头开始重新打开项目.关闭Visual Studio后,问题再次发生.
c# xaml visual-studio-2013 win-universal-app visual-studio-2015
我正在进行8.1 Universal转换为UWP.我在代码隐藏中有一些代码,可以从视图模型数据中以编程方式在堆栈面板中创建数百个节点.我正在尝试为其中一些节点添加一些可视化响应规则.
我正在使用的模式基本上是:
foreach (var item in ViewModel.items)
{
var fooStackPanel = CreateItemRowStackPanel();
fooStackPanel.Children.Add(CreateItemImage(item.ProductUrl));
fooStackPanel.Children.Add(CreateItemNameTextBlock(item.Name));
// ...
LayoutGrid.Children.Add(fooStackPanel);
}
Run Code Online (Sandbox Code Playgroud)
在那里的某个地方,我想为特定节点添加响应规则.
以下是我想要做的事情,看看XAML,但我需要在后面的代码中做这些设置器.我该怎么办?
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="WindowStates">
<VisualState x:Name="NarrowState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<!-- How do I add these programmatically in the code behind? -->
<Setter Target="Item1Image.Visibility"
Value="Collapsed" />
<Setter Target="Item2Image.Visibility"
Value="Collapsed" />
<!-- ... -->
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
Run Code Online (Sandbox Code Playgroud) 如何在Windows Phone 8.1中的Hub控件中关闭标题移动?就像在"MixRadio"应用程序中一样.
我试图找到这样的属性设置,但我没有成功.
<Hub x:Name="HubControl" HorizontalAlignment="Left" Margin="0,25,0,0" VerticalAlignment="Top" Height="640" Background="Black">
<Hub.Header>
<StackPanel>
<TextBlock FontSize="48" FontFamily="Segoe WP Semibold">
<Run FontWeight="Bold" Text="An"/>
<Run FontWeight="Normal" Text="App"/>
</TextBlock>
<TextBlock FontSize="18" Margin="0,18,0,0" FontFamily="Segoe WP Semibold" Text="updating mix..."/>
</StackPanel>
</Hub.Header>
<HubSection>
<DataTemplate>
<Grid>
<TextBlock FontSize="18" Margin="0,18,0,0" FontFamily="Segoe WP Semibold" Text="1 page"/>
</Grid>
</DataTemplate>
</HubSection>
<HubSection>
<DataTemplate>
<Grid>
<TextBlock FontSize="18" Margin="0,18,0,0" FontFamily="Segoe WP Semibold" Text="2 page"/>
</Grid>
</DataTemplate>
</HubSection>
</Hub>
Run Code Online (Sandbox Code Playgroud)
第二个问题:如何删除第一个和第二个标题文本之间的空格?
我收到了错误
操作数类型与运算符不兼容
在尝试比较两个"真实"数据类型时的标题中.
任何人都可以帮我解决错误吗?
public void clicked()
{
real localAnnualUsage = itemSetup_DS.AnnualUsage();
real localSalesPrice = itemSetup.StockPrice;
real localCost = itemSetup.StockCost;
real localstockInventAvg = itemSetup.StockInventAvg;
real localTurnAndEarn;
real localAnnualGP;
real localAvgInvCost;
;
localAvgInvCost = itemSetup.StockInventAvg;
if (localStockInventAvg != itemSetup_StockInventAvg)
{
localAvgInvCost = itemSetup_StockInventAvg;
}
//...
}
Run Code Online (Sandbox Code Playgroud)
错误发生在条件行上.