小编Jen*_*wka的帖子

AdaptiveTrigger和DataTemplate

AdaptiveTrigger是否可以在DataTemplate中工作?

这是我用来自定义我的ShellNavigation的代码,除了视觉状态之外它工作得很好.它们不会触发任何东西.

<shell:ShellHeadView x:Key="ShellHeadView_01">
    <shell:ShellHeadView.ContentTemplate>
        <DataTemplate>
            <Grid Margin="20,0">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup>
                        <VisualState x:Name="GreenBackgroundVisualState">
                            <VisualState.Setters>
                                <Setter Target="headViewLeft.Background" Value="Green" />
                            </VisualState.Setters>
                            <VisualState.StateTriggers>
                                <AdaptiveTrigger MinWindowWidth="1000"/>
                            </VisualState.StateTriggers>
                        </VisualState>
                        <VisualState x:Name="OrangeBackgroundVisualState">
                            <VisualState.Setters>
                                <Setter Target="headViewLeft.Background" Value="Orange" />
                            </VisualState.Setters>
                            <VisualState.StateTriggers>
                                <AdaptiveTrigger MinWindowWidth="2000"/>
                            </VisualState.StateTriggers>
                        </VisualState>
                        <VisualState x:Name="RedBackgroundVisualState">
                            <VisualState.Setters>
                                <Setter Target="headViewLeft.Background" Value="Red" />
                            </VisualState.Setters>
                            <VisualState.StateTriggers>
                                <AdaptiveTrigger MinWindowWidth="3000"/>
                            </VisualState.StateTriggers>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid Grid.Column="0" x:Name="headViewLeft" Width="100" Height="90">

                </Grid>
Run Code Online (Sandbox Code Playgroud)

c# windows-runtime win-universal-app windows-10 uwp

24
推荐指数
1
解决办法
5144
查看次数

如何在Windows 10 Universal中获取设备的唯一标识符?

这是我的旧实现,用于获取Windows Universal 8.1的唯一DeviceID,但类型HardwareIdentification不再存在.

    private static string GetId()
    {
        var token = HardwareIdentification.GetPackageSpecificToken(null);
        var hardwareId = token.Id;
        var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);

        byte[] bytes = new byte[hardwareId.Length];
        dataReader.ReadBytes(bytes);

        return BitConverter.ToString(bytes).Replace("-", "");
    }
Run Code Online (Sandbox Code Playgroud)

c# windows-runtime win-universal-app windows-10

20
推荐指数
3
解决办法
2万
查看次数

MSSQL BIT_COUNT(汉明距离)

有什么功能类似于BIT_COUNTMSSQL中的MYSQL 功能吗?我想在MSSQL中创建一个非常简单的汉明距离函数,我可以在我的选择中使用它.

这是我对MYSQL的看法:

CREATE FUNCTION `HAMMINGDISTANCE`(`hasha` BIGINT, `hashb` BIGINT)
    RETURNS int(11)
    DETERMINISTIC
    RETURN 
    BIT_COUNT(hasha^hashb)
Run Code Online (Sandbox Code Playgroud)

mysql sql sql-server

6
推荐指数
1
解决办法
1046
查看次数

如何在Windows Universal 10 App中获得没有Exception的StackTrace

我知道可以使用:

System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace();
Run Code Online (Sandbox Code Playgroud)

但这似乎不再起作用,因为它需要一个Exception-Object.

c# windows-runtime win-universal-app windows-10 uwp

6
推荐指数
1
解决办法
2345
查看次数

SqlParameter(String,Object)无法处理常量值

我有一个函数,可以向SQL Server数据库发送两个请求。但是,在第二个请求上,我得到一个SqlException并且参数@mpe丢失。如果我尝试0在的构造函数中设置常量值SqlParameter

    protected static string GetX(int mpe, string xsection, string xkey)
    {
        var xSetup = App.Current.Db.GetType<Data.CachedTypes.XSetup>(
            "where mpehotel=@mpe and xsection=@xsection and xkey=@xkey",
            new System.Data.SqlClient.SqlParameter("@mpe", mpe),
            new System.Data.SqlClient.SqlParameter("@xsection", xsection),
            new System.Data.SqlClient.SqlParameter("@xkey", xkey));

        if (mpe > 0 && xSetup == null)
        {
            // Fallback mechanism. Always tries to get the default for all MPEs.
            xSetup = App.Current.Db.GetType<Data.CachedTypes.XSetup>(
                "where mpehotel=@mpe and xsection=@xsection and xkey=@xkey",
                new System.Data.SqlClient.SqlParameter("@mpe", 0), <-- THIS FAILES!!
                new System.Data.SqlClient.SqlParameter("@xsection", xsection),
                new System.Data.SqlClient.SqlParameter("@xkey", …
Run Code Online (Sandbox Code Playgroud)

c# sql-server sqlparameter

3
推荐指数
1
解决办法
303
查看次数

ReSharper代码注释异步任务&lt;T&gt;

是否可以标记的结果async Task<T>可以为null?使用属性[CanBeNull]不起作用,因为异步Task的返回值永远不会为null。

[CanBeNull] // not working...
private async Task<T> doSomeFancyAsyncStuff([NotNull] object icantbenull) { ...
Run Code Online (Sandbox Code Playgroud)

.net c# resharper annotations async-await

2
推荐指数
1
解决办法
219
查看次数