我有一个使用Caliburn.Micro的WPF应用程序.DataGrid绑定到ViewModel中的对象集合.您能否建议一种过滤DataGrid内容的方法,如果可能的话,可以通过任何字段进行过滤?
谢谢.
我有一个System.Net.Mail.Attachment对象,其中包含一些.csv数据.我需要将附件的内容保存在文件中.我试过这个:
var sb = new StringBuilder();
sb.AppendLine("Accounts,JOB,Usage Count");
sb.AppendLine("One,Two,Three");
sb.AppendLine("One,Two,Three");
sb.AppendLine("One,Two,Three");
var stream = new MemoryStream(Encoding.ASCII.GetBytes(sb.ToString()));
//Add a new attachment to the E-mail message, using the correct MIME type
var attachment = new Attachment(stream, new ContentType("text/csv"))
{
Name = "theAttachment.csv"
};
var sr = new StreamWriter(@"C:\Blah\Look.csv");
sr.WriteLine(attachment.ContentStream.ToString());
sr.Close();
Run Code Online (Sandbox Code Playgroud)
但该文件只有以下内容:"System.IO.MemoryStream".你能告诉我如何在那里得到真实的数据吗?
谢谢.
我有一个下拉列表,我希望在更改选择时调用特定的操作方法.这是我的下拉列表:
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "ediFilesForm" }))
{
var directoriesSelectList = new SelectList(Model.Directories);
@Html.DropDownListFor(m => m.SelectedDirectory, directoriesSelectList, new {@Id = "Directories", @style = "width:Auto;height=Auto;", @size = 10, onchange = "$('#ediFilesForm').submit()", name="action:FolderChange"})
Run Code Online (Sandbox Code Playgroud)
这是动作方法:
[HttpPost]
[ActionName("FolderChange")]
public ActionResult FolderChange(EdiFileModel ediFileModel)
{
//do your work here
return View("Index", ediFileModel);
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,这种方法永远不会被击中,但是这个方法却被命中:
public ActionResult Index()
{
...
return View(ediFileModel);
}
Run Code Online (Sandbox Code Playgroud)
能否请你帮忙?
我有一个ListView, 我需要将它的原生colors(所选项目和其他项目)替换为不同的颜色。我无法找到如何做到这一点。我可以将背景颜色更改为不同的颜色(请参阅下面的代码),但我不知道如何使其表现得像普通的ListView、在选择时更改项目颜色。
这是我的代码:
<ListView x:Name="MenuItemsListView"
SeparatorVisibility="None"
HasUnevenRows="true"
ItemsSource="{Binding MenuItems}">
<ListView.Header>
<Grid BackgroundColor="Black">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Image Grid.Column="1" Grid.Row="1" WidthRequest="50" HeightRequest="50" HorizontalOptions="StartAndExpand" Source="Assets\logo.png" />
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Height="100">
<StackLayout Padding="15,10"
Orientation="Horizontal"
HorizontalOptions="FillAndExpand"
BackgroundColor="{StaticResource LogoBackgroundColor}">
<Image WidthRequest="50" Source="{Binding IconSource}" />
<Label VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center"
Text="{Binding Title}"
FontSize="24"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Run Code Online (Sandbox Code Playgroud) 我的 Xamarin.Forms 应用程序中的视图上有一个 AbsoluteLayout,其中有 3 个按钮。以编程方式添加另一个控件后,它会覆盖按钮。我不知道如何使按钮始终位于前面。
<ContentPage.Content>
<AbsoluteLayout x:Name="Container" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Button
Style="{StaticResource CallButtonStyle}"
...
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds=".85,.02"
Text="{Binding CameraSwitchIcon}" />
<Button
...
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds=".15,.95,80,80"
Text="{Binding VideoToggleIcon}" />
<Button
...
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds=".85,.95,80,80"
Text="{Binding AudioToggleIcon}" />
</AbsoluteLayout>
</ContentPage.Content>
Run Code Online (Sandbox Code Playgroud) 这是我的代码的一部分:
<asp:ListBox ID="lbRD" runat="server" DataSourceID="RDSqlDataSource" onchange="JSFillDetail();" DataTextField="????????" DataValueField="ID" Width="188px" Height="200px"/>
<asp:TextBox ID="txtDescription" runat="server" />
<asp:RequiredFieldValidator ID="txtDescriptionRequiredFieldValidator" runat="server" ErrorMessage="???????? ???????? ???????????? ??? ??????????" ControlToValidate="txtDescription" />
Run Code Online (Sandbox Code Playgroud)
我的页面上有一个列表框,一个文本框和一个必填字段验证器.当用户从列表框中选择某些内容时,所选项目将使用javascript函数显示在文本框中.提交页面时,验证程序会在文本框为空时报告错误.如果之后用户从列表框中选择了某些内容,则仍会显示错误消息,即使文本框不再为空.如何让验证器验证文本框,甚至更好地清除填充文本框的javascript函数中的错误消息?谢谢,大卫
你能告诉我是否有任何与SQL Server的Access'DISTINCTROW相同的东西?
我有一个MyTable表和一个字段MyField,它是varbinary(max).我有以下查询:
SELECT COUNT(*) FROM MyTable WHERE MyField IS NOT NULL
Run Code Online (Sandbox Code Playgroud)
SELECT子句可以有任何东西,没关系.由于Where子句中的varbinary MyField,执行永远不会结束.
我甚至试过这个:
SELECT Size
FROM
(
SELECT ISNULL(DATALENGTH(MyField), 0) AS Size FROM MyTable
) AS A
WHERE A.Size > 0
Run Code Online (Sandbox Code Playgroud)
内部查询工作正常,没有Where子句的整个查询工作正常,但使用Where子句它被卡住了.有人可以向我解释一下吗?
谢谢.
我的 Blazor 服务器端应用程序使用 Azure B2C 进行身份验证。注销后,用户将被重定向到通知注销成功的通用页面。如何使应用程序重定向到主页(即登录页面)?
这是我的身份验证的一部分:
<AuthorizeView>
<Authorized>
@if (canEditProfile)
{
<a href="MicrosoftIdentity/Account/EditProfile" style="color: white">Hello, @context.User.Identity.Name!</a>
}
else
{
<span style="color: white">Hello, @context.User.Identity.Name!</span>
}
<a href="MicrosoftIdentity/Account/SignOut" style="color: white">Log out</a>
</Authorized>
<NotAuthorized>
<a href="MicrosoftIdentity/Account/SignIn" style="color: white">Log in</a>
</NotAuthorized>
</AuthorizeView>
Run Code Online (Sandbox Code Playgroud) 我有一个集合FileTypes,其中包含FileType类型的对象.该类型具有字段CounterpartyId.我还有一个Counterparty类型的对象的Counterparties,它有字段ID.你能否帮我过滤掉所有ID不等于任何FileType的CounterpartyId的交易对手,使用LINQ.谢谢
你能帮我把 BaseClass 的 ObservableCollection 转换成 DerivedClass 的 IEnumerable 吗?
谢谢。
c# ×4
sql-server ×2
xaml ×2
asp.net ×1
azure-ad-b2c ×1
datagrid ×1
filtering ×1
javascript ×1
linq ×1
listview ×1
wpf ×1
xamarin ×1