小编MNi*_*Nie的帖子

如何在网格上拉伸按钮,xaml

我在整个网格上拉伸按钮时遇到问题.

我的代码看起来像这样:

<Grid x:Name="LayoutRoot" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="2*"/>
        <RowDefinition Height="8*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <StackPanel Grid.Column="5" Grid.Row="1" Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Button Content="Search" Background="#FF13D38D" Click="searchButton_Click" FontSize="48"/>
    </StackPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)

但它对我不起作用,并在整个网格上拉伸按钮,我尝试了maxwidth/maxheight但它也没有正常工作任何人都有想法?

xaml stackpanel wpf-grid

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

如何从xml获取数据,由linq,c#

嗨,

我从youtube xml获取数据时出现问题:youtube xml的地址:http://gdata.youtube.com/feeds/api/videos? q = keyword&orderby = viewCount

我试试这个,但程序没有进入linq查询.

key = @"http://gdata.youtube.com/feeds/api/videos?q="+keyword+@"&orderby=viewCount";
youtube = XDocument.Load(key);
urls = (from item in youtube.Elements("feed")
       select new VideInfo
       {
            soundName = item.Element("entry").Element("title").ToString(),
            url = item.Element("entry").Element("id").ToString(),
       }).ToList<VideInfo>();
Run Code Online (Sandbox Code Playgroud)

任何人都有想法,如何解决这个问题?谢谢!

c# xml linq youtube microsoft-metro

5
推荐指数
1
解决办法
213
查看次数

使用 Autofac 和 EF Core 3.1 的内存泄漏(从 2.2 迁移后)

将 EF Core 3.1.5(从 2.2 迁移后)与 Autofac 5.2.0 一起使用时,我遇到了内存泄漏。我的情况是,在主页上我加载了一些产品列表,每次重新加载页面都会增加 5-10mb 的内存使用量,内存无休止地增加。它永远不会下降。我怀疑我的注册错误(?)或者这是因为 EF Core 中的跟踪行为(?)。我尝试注册我的MyDbContext的如下:

public class DbContextModule<TContext> : Module
    where TContext : DbContext
{
    protected override void Load(ContainerBuilder builder)
    {
        base.Load(builder);

        builder
            .RegisterType<TContext>()
            .WithParameter("options", DbContextOptionsFactory.Get<TContext>())
            .InstancePerLifetimeScope();
    }
}

public class DbContextOptionsFactory
{
    public static DbContextOptions<TContext> Get<TContext>() where TContext : DbContext
    {
        var confSql = "fake";

        var builder = new DbContextOptionsBuilder<TContext>();
        DbContextConfigurer.Configure<TContext>(builder, confSql);

        return builder.Options;
    }
}

public class DbContextConfigurer
{
    public static void Configure<TContext>(DbContextOptionsBuilder<TContext> builder, string connectionString) where …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework-core .net-core asp.net-core ef-core-3.1

5
推荐指数
1
解决办法
505
查看次数

将 F# func 转换为 Expression&lt;Func&lt;..,..&gt;&gt;

我有一个带有以下签名的函数的模块:

module Something =
    let someFunc func = // ('TType -> 'TField) -> 'TValue
        ...
Run Code Online (Sandbox Code Playgroud)

在该函数中,我从某个外部库调用了一个函数,该函数具有以下签名(C#)的方法:

class SomeClass
{
    public ReturnType<TType> SomeMethod<TField>(func: Expression<Func<TType, TField>>) { ... }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试在'TType -> 'TField那里传递一个函数时,我收到一个错误,提示它不能转换为Expression<Func<'TType, 'TField>>. 我在 StackOverflow 上发现了以下问题:question

但这并没有解决我的问题(第一个答案不起作用,第二个答案有效,但我必须更改函数的签名)。

对于第二个答案,我必须将函数的签名更改为以下内容:

module Something =
    let someFunc func = // Expression<Func<'TType, 'TField>>) -> 'TValue
        ...
Run Code Online (Sandbox Code Playgroud)

添加对我的模块的“客户端”可见的附加类,如下所示:

type ExpressionHelper() =
    static member AsExpression<'TType, 'TField>(e: Expression<Func<'TType, 'TField>>) = e
Run Code Online (Sandbox Code Playgroud)

所以最后的调用看起来像这样:

let _ = Something.someFunc (fun (o: SomeType) -> o.someField)
Run Code Online (Sandbox Code Playgroud)

看起来像这样:

let _ …
Run Code Online (Sandbox Code Playgroud)

lambda f# casting c#-to-f#

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

如何单独的字符串,c#

我从这个字符串中获取'关键字'有问题,我尝试了string.replace()但它没有用,有没有人知道,如何从这个字符串中分离关键字?

var url = "< id xmlns=\"http://www.w3.org/2005/Atom\">http://gdata.youtube.com/feeds/api/videos/keyword< /id>";
Run Code Online (Sandbox Code Playgroud)

感谢帮助!

c# xml youtube string

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