小编Mec*_*h0z的帖子

如何将R.drawable作为参数传递,以便我可以解析图像

我尝试将一个独特的图像保存到每个对象,但我得到这个错误,构造函数应该如何寻找它以这种方式工作?构造函数Beer(String,int,int)未定义

m_beer = new ArrayList<Beer>();
              final Beer b1 = new Beer("Tuborg", 7, R.drawable.tuborg);
              final Beer b2 = new Beer("Carlsberg", 7, R.drawable.carlsberg);
              final Beer b3 = new Beer("Urquel", 9, R.drawable.urquel);


public class Beer 
{
    //Members
    private String name;
    private int color; //1 = Very dark 10 = Very light
    private R.drawable icon;

    //Methods
    public Beer(String name, int color, R.drawable icon)
    {
        this.name = name;
        this.color = color;
        this.icon = icon;
    }

    public String getName()
    {
        return name;
    }
    public void setName(String …
Run Code Online (Sandbox Code Playgroud)

java android

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

在WCF中使用共享数据类型作为DataContract

从我所看到的,我必须为我想通过WCF传输的每种数据创建一个"特殊"数据类型,所以如果我有一个像这样的共享类

public class District
{
    public long Id { get; set; }
    public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我想使用WCF发送一个District对象,我必须创建一个datacontract,因此我必须创建一个新的WCF类

[DataContract]
public class WCFDistrict
{
    [DataMember]
    public long Id { get; set; }

    [DataMember]
    public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

然后当我在我的实现中的WCF服务中使用它时,我必须将数据从一个对象解析到另一个对象

public WCFDistrict GetDistrict(long id)
{
    var district = _districtRepository.GetDistrict(id);
    return new WCFDistrict {Id = district.Id, Name = district.Name};
}
Run Code Online (Sandbox Code Playgroud)

有没有办法只重用共享类作为DataContract,而没有这些属性?或者我应该在他们可以共享的类上创建一个接口,以便我可以在它们之间进行转换?还是第三种?

c# wcf

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

是否可以将调试数据从VS复制到Linqpad?

我喜欢linqpad,但是当我需要它时,我在Visual Studio中有一些我需要做的事情.

因此,我很想知道是否可以将一些数据列表复制到Linqpad中,创建必要的类并将相同的值插入到列表中,因此我可以使用实际数据

所以我会调试并在断点中得到这样的东西:

在此输入图像描述

然后我想在linqpad的列表中找到我可以使用的那5个项目

c# linqpad visual-studio

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

设置TemplateField HeaderText动态以进行本地化

我正在尝试为我的ASP.NET代码创建本地化,但是我在设置TemplateField的HeaderText时遇到了问题

我有这个有效

                        <asp:TemplateField HeaderText="Description">
                        <ItemTemplate>
                            <%# Eval("Description") %>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Panel ID="Panel5" runat="server" DefaultButton="EditSubmission">
                                <asp:TextBox runat="server" ID="Submission_DescriptionTxtBox" TextMode="MultiLine"
                                ToolTip='<%# GetById("atforbedringsforslag_description_tooltip") %>'/>

                                </asp:Panel>
                        </FooterTemplate>
                    </asp:TemplateField>
Run Code Online (Sandbox Code Playgroud)

但我想改变

<asp:TemplateField HeaderText="Description">
Run Code Online (Sandbox Code Playgroud)

<asp:TemplateField HeaderText='<%# GetById("atforbedringsforslag_description_title") %>'>
Run Code Online (Sandbox Code Playgroud)

但后来我明白了

仅在具有DataBinding事件的对象上支持数据绑定表达式.System.Web.UI.WebControls.TemplateField没有DataBinding事件.

我该如何设置此字段?我可以找到一些使用OnRowCreated,但随后你访问带有索引号的字段,然后很容易出错或忘记更改索引如果以后添加新字段


编辑我的解决方案:

创建自定义表达式构建器

using System.Web.Compilation;
using System;
using System.CodeDom;

public class LocalizationExpressionBuilder : ExpressionBuilder
{
    public override CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
    {
        CodeExpression[] inputParams = new CodeExpression[] { new CodePrimitiveExpression(entry.Expression.Trim()), 
                                                    new CodeTypeOfExpression(entry.DeclaringType), 
                                                    new CodePrimitiveExpression(entry.PropertyInfo.Name) };

        // Return a CodeMethodInvokeExpression that will invoke the …
Run Code Online (Sandbox Code Playgroud)

asp.net data-binding

4
推荐指数
1
解决办法
5275
查看次数

在MVVM中数据绑定ObservableCollection <T>

我有一个带有Datatemplate的ListView,它包含一个电影列表.它被数据绑定到ObservableColection,但每当我编辑Movie.Name时,即使在我的PropertyChangedEventHandler中调用"Name"并使用"Name"调用它,它也不会更新ListView.

我在我的初始化程序中为我的收藏添加了2个"电影",这些都显示正确(Klovn the Movie,Taken)

因此,当我单击编辑时,它应该更改所选电影的文本并将其名称更改为"测试"并且更改,但更改未显示在ListView中,但如果我使用foreach输出Collection,则Name is Test.

View.xaml

<Window x:Class="MovieDB3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="File">
                <MenuItem Header="Edit" Click="MenuEditClick"/>
            </MenuItem>
        </Menu>
        <Grid DockPanel.Dock="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <ListView VerticalAlignment="Stretch" Name="ListViewMovies" ItemsSource="{Binding Path=Collection}" IsSynchronizedWithCurrentItem="True" >
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <WrapPanel>
                            <TextBlock Text="{Binding Path=Name}"/>
                        </WrapPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </Grid>
    </DockPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)

View.cs

using System;
using System.Windows;
using MovieDB3.Models;
using MovieDB3.ViewModels;

namespace MovieDB3
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class …
Run Code Online (Sandbox Code Playgroud)

.net c# data-binding wpf xaml

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

如何将SelectedDateChanged事件从DatePicker绑定到VM中的Command

我有一个带有空代码隐藏文件的wpf文件(如果可能,我想保持代码隐藏为空)

http://pastebin.com/x1CTZDFK

然后我有了这个viewmodel文件

using System;
using System.Collections.ObjectModel;
using System.Windows.Input;
using MVVM_Test.Model;
using MvvmFoundation.Wpf;

namespace MVVM_Test.ViewModel
{
    public class ViewModel : ObservableObject
    {
        private DateTime selectedDate;
        public DateTime SelectedDate
        {
            get
            {
                return selectedDate;
            }
            set
            {
                selectedDate = value;
                RaisePropertyChanged("SelectedDate");
            }
        }

        private DateTime startDate;
        public DateTime StartDate
        {
            get { return startDate; }
            set
            {
                startDate = value;
                RaisePropertyChanged("StartDate");
            }
        }

        private DateTime endDate;
        public DateTime EndDate
        {
            get { return endDate; }
            set
            {
                endDate = value;
                RaisePropertyChanged("EndDate"); …
Run Code Online (Sandbox Code Playgroud)

.net c# wpf

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

从WPF中的ListBox中获取单击元素

我有一个带有datatemplate的列表框

<Button Name="ButtonSortDate" Content="Date" Grid.Column="1" Click="ButtonSortDateClick" />
<Button Name="ButtonSortABC" Content="ABC.." Grid.Column="2" Click="ButtonSortABCClick" />
<!--ItemsSource="{Binding NotesCollection}"-->
<ListBox Name="ListBoxNotes" 
    Grid.Row="1" Grid.ColumnSpan="3"                             
    DoubleTap="DeleteDoubleTap">
    <ListBox.ItemTemplate>                            
        <DataTemplate>
            <StackPanel Margin="0,0,0,17" Width="432" Height="78" >
                <TextBlock Text="{Binding NoteText}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" />
                <TextBlock Text="{Binding Date}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)

我希望能够点击列表中的项目来删除它,但我找不到任何方法来获取所点击的项目,只有选中的(这并不总是相同)

如果我例如点击列表中的项目1并且dobble点击第二个项目,那么ListBox.SelectedItem将是第一个项目.

我如何获得第2项?如果我可以在模板中以某种方式在项目本身上放置一个事件,那将会很好

.net c# wpf xaml windows-phone-7

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

Xaml 获取状态栏停靠在底部

我无法让我的状态栏显示在底部。当我将它停靠在底部时,它不应该这样工作吗?

<DockPanel>
    <Menu DockPanel.Dock="Top">
        <MenuItem Header="File">
            <MenuItem Header="Open" />
            <MenuItem Header="Save As" />
            <MenuItem Header="Save" />
            <MenuItem Header="Exit" />
        </MenuItem>
    </Menu>
    <ToolBarPanel DockPanel.Dock="Left">
        <Button>Næste</Button>
        <Button>Frem</Button>
    </ToolBarPanel>
    <RichTextBox DockPanel.Dock="Right"></RichTextBox>
    <StatusBar DockPanel.Dock="Bottom">test</StatusBar>
</DockPanel>
Run Code Online (Sandbox Code Playgroud)

c# xaml

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

使用MVVM Light消息创建新的对话窗口时,获取"调用线程必须是STA"

我有一个对话窗口,在我的Views View-Model中收到一条消息时显示

对话框就在这里http://pastebin.com/BAeCLwhz(我知道我应该有一个空的代码隐藏,但是将它变为空是第二优先,所以现在不是问题!)

我在我的Projects View-Model中创建窗口

MessengerInstance.Register<bool>(this, "Homing", ShowHomingDialog);

private void ShowHomingDialog(bool b)
    {
        HomingRobot hb = new HomingRobot();
        hb.ShowDialog();
    }
Run Code Online (Sandbox Code Playgroud)

但是当它运行时我得到"调用线程必须是STA"我尝试在项目代码隐藏而不是在viewmodel中调用对话框,但这给了我相同的结果.那么我怎么能让我的窗口弹出而不是"多线程",即使使用消息也是如此?

.net c# wpf mvvm-light

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

不能用Combres和yui缩小

我不知道如何找到更多关于我的.js文件错误的信息,但是如果我转"defaultDebugEnaled = true"那么它工作正常,但是把它设置为false会让我得到这个错误

而且我似乎无法切换任何东西以使它给我一个更具体的错误,我只知道它在尝试缩小它时失败了.

此外,这只发生在我包含一个特定文件时,但这是工作,所以不能只发布该文件.

 Server Error in '/' Application.

 [ERROR] missing formal parameter

 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.InvalidOperationException: [ERROR] missing formal parameter

 Source Error: 

 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using …
Run Code Online (Sandbox Code Playgroud)

javascript minify combres

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

"[变量]在定义之前使用"错误

我有几个这些错误,我不知道如何"正确"解决它,问题是我有很多javascript文件(分离,以便于维护),我包括插件等.

所以在这个例子中我使用来自http://www.openjs.com/scripts/events/keyboard_shortcuts/的快捷方式

这只是定义了快捷方式

shortcut = {.......
Run Code Online (Sandbox Code Playgroud)

然后,当我在我的代码中使用它时

 shortcut.add("F1", function () { showDialog(); }, { 'type': 'keydown', 'propagate': false, 'target': editor_document });
Run Code Online (Sandbox Code Playgroud)

jslint会抱怨

JS Lint:在定义之前使用了'快捷方式'.

我也有自己的代码,我使用在其他文件中声明的函数,所以解决这个问题的"正确"方法是什么

javascript jquery jslint

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

为Task/Intent提供单声道跨平台支持

我有WP7和Android的应用程序,这个应用程序必须支持"任何"连接类型(WiFi,NFC,蓝牙等)

然后我创建了一个MVVMCross https://github.com/slodge/MvvmCross的分层模型

我有一个接口,例如Android蓝牙必须实现

interface IConnectionService
{
    List<TargetDevice> FindDevices();
    void Connect(TargetDevice targetDevice);
    void Disconnect();
    byte[] Read();
    void Write(byte[] command);
}
Run Code Online (Sandbox Code Playgroud)

我希望能够请求用户进行蓝牙访问,但我不想将我的UI专门编程到Android蓝牙,因此视图和视图模型不应该知道使用了哪个意图,所有这些都应该由类来处理实现IConnectionService

问题是它应该适用于不使用意图的Windows Phone,它使用任务,那么如何创建一个允许我发出Intent请求或任务请求的接口,而无需任何人知道需要什么类型的请求?

c# mono mvvm xamarin.android mvvmcross

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