小编Rob*_*cus的帖子

WPF窗口位置

我在WPF上需要帮助......

当用户移动/拖动/更改第一页窗口(mainwindow.xaml)的位置时,用户点击"下一步"按钮进入第二页(process.xaml),窗口(process.xaml)不在与用户之前移动到的(mainwindow.xaml)相同的位置.如何让它记住整个窗口的位置?当用户关闭窗口并再次运行时,除非用户移动窗口,否则窗口将默认显示在中心.

真的需要帮助.谢谢.

c# wpf position window

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

Generic PropertyEqualityComparer <T>

我已经开发了一个通用的PropertyEqualityComparer工作正常,但我不确定我是否以正确的方式完成它,所以如果有些人可以改进代码或评论家,他是受欢迎的.

注意:如果是Reference类型,属性应该实现IEquatable.

    public sealed class PropertyEqualityComparer<T> : IEqualityComparer<T>
{
    private readonly Type _iequatable = Type.GetType("System.IEquatable`1", false, true);
    private readonly PropertyInfo _property;

    public PropertyEqualityComparer(string property)
    {
        PropertyInfo propInfos = typeof(T).GetProperty(property);
        if (propInfos == null)
        {
            throw new ArgumentNullException();
        }

        // Ensure Property is Equatable (override of HashCode)
        if (propInfos.PropertyType.IsValueType
            || (!propInfos.PropertyType.IsValueType
                && propInfos.PropertyType.GetInterfaces().Any(type => type.Name == _iequatable.Name)))
        {
            _property = propInfos;
        }
        else
        {
            throw new ArgumentException();
        }
    }

    public bool Equals(T x, T y)
    {
        var xValue = _property.GetValue(x, null); …
Run Code Online (Sandbox Code Playgroud)

c# generics

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

在Windows Phone 7上将图像转换为字节数组没有System.Drawing Dll任何其他方式?

Byte[] result = (Byte[])new ImageConverter().ConvertTo(img1, typeof(Byte[]));

//I cant use Image Converter add Image Class ? Drawing dll 

MemoryStream ms = new MemoryStream();

img1.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);

return ms.ToArray();

//Cannot see System.Drawing dll and there is no  sth like Drawing.Imaging... 
Run Code Online (Sandbox Code Playgroud)

有没有其他选项,而不是从外部源添加DLL(我的意思是我将它复制,然后将其添加为外部DLL)?我的项目是在Windows 7手机应用程序中,无法看到Drwaing.dll stj

谢谢

binary system.drawing image windows-phone-7

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

将Eval格式化为货币,强制使用en-US

我有这行代码:

<%# Eval( "Balance", "{0:C}" )%>
Run Code Online (Sandbox Code Playgroud)

我如何总是强制它在en-US中显示货币而不管他们设置的是什么语言环境?

c# asp.net

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

将selecteditem设置为listpicker

XAML

 <DataTemplate x:Name="PickTmplItemTipo">
            <StackPanel Orientation="Horizontal">               
                <TextBlock Text="{Binding tipo}" />                
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Name="PickTmplFullTipo">            
            <StackPanel Orientation="Horizontal" Margin="0,25,0,0">
                <TextBlock Name="lblTipo" Width="350" Text="{Binding tipo}" FontFamily="{StaticResource PhoneFontFamilyLight}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeExtraLarge}" />
            </StackPanel>
        </DataTemplate>


<toolkit:ListPicker    
         Grid.Row="0"
         ItemsSource="{Binding}" Margin="21,0,22,0" 
         Header="{Binding Source={StaticResource LocalizedStrings}, Path=Localizedresources.strTipoUni}" 
         FullModeHeader="{Binding Source={StaticResource LocalizedStrings}, Path=Localizedresources.strTipoUni}" 
         FullModeItemTemplate="{Binding Source={StaticResource PickTmplFullTipo}}" 
         ItemTemplate="{Binding Source={StaticResource PickTmplItemTipo}}" 
         Name="lPickTipo" 
         TabIndex="0" 
         Height="98" 
         VerticalAlignment="Top" 
         ExpansionMode="FullScreenOnly" 
         Tap="lPickTipo_Tap" 
         SelectionChanged="lPickTipo_SelectionChanged" />
Run Code Online (Sandbox Code Playgroud)

C#

填写listpicker:

    List<tipos> _lstTipos { get; set; }
    private void cargaLista()
    {
        using (serviciosDBDataContext miDataContext = new serviciosDBDataContext(conn))
        {
            _lstTipos = miDataContext.tipos.ToList();
        }

        this.lPickTipo.ItemsSource = …
Run Code Online (Sandbox Code Playgroud)

selecteditem windows-phone-7 listpicker

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

从数据库到日期时间选择器

我有一个日期时间选择器很少的表单,确切地说是两对日期和时间。

在此处输入图片说明

来自这些选择器的数据被合并并以 DateTime 格式保存到数据库中

 16/05/2012 11:28:00 a.m.
Run Code Online (Sandbox Code Playgroud)

现在,我想做的是从数据库中获取值并将其放入日期时间选择器中。

我试过类似的东西

string plannedDate =(dbFunctions.SQLReadColumn("task", "PlannedDate", TaskID));
        DateTime pDate = new DateTime(plannedDate.Substring(0,9);
        dtpDatePicker.Value=pDate;
Run Code Online (Sandbox Code Playgroud)

其中plannedDate包含上述格式的字符串数据,但我无法将其转换为DateTime(第二行不正确)。有没有简单的方法来做到这一点,还是我必须将绳子切成年、月等的碎片?

c# datetime

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

如何获取特定月份/年中特定日期的总数?

假设我想知道2014年2月的星期一数量.

我知道这将使用DateTime类,但是希望看到一些编码示例.

c# datetime

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