我有一个窗口中包含的列表(见下文).窗口DataContext
有两个属性,Items
和AllowItemCommand
.
如何获取针对窗口的属性需要解析Hyperlink
的Command
属性DataContext
?
<ListView ItemsSource="{Binding Items}">
<ListView.View>
<GridView>
<GridViewColumn Header="Action">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock>
<!-- this binding is not working -->
<Hyperlink Command="{Binding AllowItemCommand}"
CommandParameter="{Binding .}">
<TextBlock Text="Allow" />
</Hyperlink>
</TextBlock>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
Run Code Online (Sandbox Code Playgroud) 我喜欢新的Office套件和Visual Studio上的窗口镶边:
我当然还在为Windows 7开发应用程序,但我想知道是否有一种快速简便的方法(阅读:WPF样式或Windows库)来模仿这种风格.我过去做过一些窗口镀铬样式,但让它看起来和行为恰到好处是非常棘手的.
有没有人知道是否有现有的模板或库来为我的WPF应用程序添加"现代UI"外观?
例如:
BitmapImage bitmap = new BitmapImage();
byte[] buffer = GetHugeByteArray(); // from some external source
using (MemoryStream stream = new MemoryStream(buffer, false))
{
bitmap.BeginInit();
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.StreamSource = stream;
bitmap.EndInit();
bitmap.Freeze();
}
Run Code Online (Sandbox Code Playgroud)
你能告诉我更多关于using
什么的吗?
编辑:
正如JaredPar的帖子中所讨论的那样,这个问题更关注Using
VS2003中的实现.有人指出,Using
直到.NET 2.0(VS2005)才引入.JaredPar发布了一个相同的解决方法.
我有这个图像(原始大小:256x256)
我制作了这个xaml定义来在我的应用程序中显示图像
<Image Grid.Row="1" Source="/MyProject;component/Images/happy.png" Stretch="Fill" Width="64" Height="64" VerticalAlignment="Top" Margin="0,0,0,0" HorizontalAlignment="Center" />
Run Code Online (Sandbox Code Playgroud)
我得到了这个结果
我怎样才能更顺利地调整大小?
我正在使用一个ObservableCollection
带有两个ICollectionView
不同的过滤器.
一种用于按某种类型过滤消息,一种用于计算已检查的消息.正如您所看到的,消息过滤器和消息计数工作正常,但是当我取消检查时,消息将从列表中消失(计数仍然有效).
对于这篇长篇文章,我很抱歉,我想包括所有相关内容.
XAML代码:
<!-- Messages List -->
<DockPanel Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="3"
Height="500">
<ListBox Name="listBoxZone"
ItemsSource="{Binding filteredMessageList}"
Background="Transparent"
BorderThickness="0">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox Name="CheckBoxZone"
Content="{Binding text}"
Tag="{Binding id}"
Unchecked="CheckBoxZone_Unchecked"
Foreground="WhiteSmoke"
Margin="0,5,0,0"
IsChecked="{Binding isChecked}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
<Button Content="Test Add New"
Grid.Column="2"
Height="25"
HorizontalAlignment="Left"
Margin="34,2,0,0"
Click="button1_Click" />
<Label Content="{Binding checkedMessageList.Count}"
Grid.Column="2"
Height="25"
Margin="147,2,373,0"
Width="20"
Foreground="white" />
Run Code Online (Sandbox Code Playgroud)
截图:
码:
/* ViewModel Class */
public class MainViewModel : INotifyPropertyChanged
{
// Constructor
public MainViewModel()
{
#region …
Run Code Online (Sandbox Code Playgroud) c# wpf observablecollection collectionviewsource icollectionview
我正在寻找一个Java Executor,它允许我指定限制/吞吐量/起搏限制,例如,不超过100个任务可以在一秒钟内处理 - 如果更多任务被提交,他们应该排队并稍后执行.这样做的主要目的是避免在遇到外部API或服务器时遇到限制.
我想知道基础Java(我怀疑,因为我检查过)或其他可靠的地方(例如Apache Commons)是否提供了这个,或者我是否必须自己编写.最好是轻量级的.我不介意自己写,但如果有一个"标准"版本在那里,我至少想先看看它.
我有一个DropDownList
我试图展示的,div
OnSelectedIndexChanged
但它说OBJECT REQUIRED
.
我绑定了DataList
那个div:
aspx:
<asp:DropDownList runat="server" ID="lstFilePrefix1" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >
<asp:ListItem Text="Prefix1" Value="Prefix1" />
<asp:ListItem Text="Prefix2" Value="Prefix2" />
<asp:ListItem Text="Prefix3" Value="Prefix3" />
<asp:ListItem Text="Prefix1 and Prefix2" Value="Prefix1 and Prefix2" />
<asp:ListItem Text="Prefix2 and Prefix3" Value="Prefix2 and Prefix3" />
</asp:DropDownList>
<asp:DataList ID="DataList1" runat="server" RepeatColumns="4"
CssClass="datalist1" OnItemDataBound="SOMENAMEItemBound"
CellSpacing="6" onselectedindexchanged="DataList1_SelectedIndexChanged"
HorizontalAlign="Center" Width="500px">
Run Code Online (Sandbox Code Playgroud)
代码背后:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstFilePrefix1.SelectedItem.Text=="Prefix2")
{
int TotalRows = this.BindList(1);
this.Prepare_Pager(TotalRows);
Page.ClientScript.RegisterClientScriptBlock(GetType(), "JScript1", "ShowDiv('data');", true); …
Run Code Online (Sandbox Code Playgroud) 首先,不CTRL+M,CTRL+O不是答案.对我来说,这正在崩溃#Region,///评论和方法,我讨厌这一点.
我想只折叠/扩展#region
部分.我正在使用Visual Studio 2012和Resharper.
我已经将滑块控件的工具提示绑定到它的Value属性,并且我正在尝试使用StringFormat使其显示"当前值{0}为10",其中{0}是Value属性.下面是我尝试解决这个问题时尝试过的各种事情之一.
<Slider.ToolTip>
<Label>
<Label.Content>
<Binding StringFormat="Current Value {0} of 10"
ElementName="DebugLevelSlider"
Path="Value" />
</Label.Content>
</Label>
</Slider.ToolTip>
Run Code Online (Sandbox Code Playgroud)
我有问题在线查找如何使用字符串文字的字符串格式,如上面的我.我看到很多字符串格式的日期/时间/货币格式转换.我认为我有一种方法可以通过多重绑定来实现这一点,但它似乎只是需要额外的工作量.我希望对于字符串文字格式我仍然不必编写自定义转换器.
在我的应用程序中,我发现自己在项目旁边使用了很多额外的标签,因此在stringformat中理解将有希望让我消除一些不必要的标签.
我将我的MenuItem的ItemsSource绑定到我的ViewModel中的ObservableCollection.这是我的xaml:
<MenuItem Header="_View"
ItemsSource="{Binding Windows}">
<MenuItem.ItemContainerStyle>
<Style>
<Setter Property="MenuItem.Header"
Value="{Binding Title}" />
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
Run Code Online (Sandbox Code Playgroud)
这部分很有用,但是现在我还想在同一个View MenuItem中添加一些静态MenuItem,用分隔符分隔.这样的东西,即使我知道这不起作用,因为我不能设置两次项目.
<MenuItem Header="_View"
ItemsSource="{Binding Windows}">
<MenuItem.ItemContainerStyle>
<Style>
<Setter Property="MenuItem.Header"
Value="{Binding Title}" />
</Style>
</MenuItem.ItemContainerStyle>
<Separator />
<MenuItem Header="item 1" />
<MenuItem Header="item 2" />
</MenuItem>
Run Code Online (Sandbox Code Playgroud)
现在我通过向MenuItem添加另一个级别来创建一个解决方法,如下所示:
<MenuItem Header="_View">
<MenuItem Header="Windows"
ItemsSource="{Binding Windows}">
<MenuItem.ItemContainerStyle>
<Style>
<Setter Property="MenuItem.Header"
Value="{Binding Title}" />
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
<MenuItem Header="Load Layout" />
<MenuItem Header="Save Layout" />
</MenuItem>
Run Code Online (Sandbox Code Playgroud)
这很好用,但如果可能的话,我宁愿没有子菜单.哦,我也更喜欢在xaml而不是代码背后执行此操作.有任何想法吗?