我试图在调试和发布配置中显示WPF控件中的不同视图元素以进行测试.我使用这篇文章作为指南: XAML是否有调试模式的条件编译器指令?(所以)
为了测试它,我创建了一个VS2013解决方案,其中包含一个名为TestingAlternateContent的WPF应用程序项目.在我的AssemblyInfo.cs中,我添加了以下代码:
#if DEBUG
[assembly: XmlnsDefinition("debug-mode", "TestingAlternateContent")]
#endif
Run Code Online (Sandbox Code Playgroud)
在我的MainWindow.xaml中,我创建了一个简单的代码示例来测试此行为,如下所示:
<Window x:Class="TestingAlternateContent.MainWindow"
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:debug="debug-mode"
mc:Ignorable="mc debug"
Title="MainWindow" Height="350" Width="525">
<Grid>
<mc:AlternateContent>
<mc:Choice Requires="debug">
<TextBlock Text="Debug mode!!" />
</mc:Choice>
<mc:Fallback>
<TextBlock Text="Release mode here!" />
</mc:Fallback>
</mc:AlternateContent>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
在测试时,我总是看到窗口显示"释放模式!" 消息,无论我使用哪种配置(Debug,Relase).我已经检查过AssemblyInfo #if DEBUG正在正常工作,当我在Debug/Release配置之间进行更改时会相应地进行更改.我已经使用.NET Framework 3.5/4.5版本在VS2008/VS2013下测试了相同的代码,但没有一个有效.我错过了什么?任何人都知道这里有什么问题或者可以发布工作代码作为参考?
有一些与此相关的帖子,但我需要澄清一些事情.我的程序中有一个结构,其中一个字段是固定大小的数组(16).这是上述结构的简化示例:
my_struct{
unsigned char my_field[16];
....
// some more fields here
};
Run Code Online (Sandbox Code Playgroud)
我想用这个字段作为地图的关键,这是我的问题. - 有没有办法使用像这样的地图
map<unsigned char[16], some_defined_structure>
Run Code Online (Sandbox Code Playgroud)
?否则,这将是以某种方式复制此char数组以适合数组或向量结构以便在之后插入地图的最佳方式?