小编Kev*_*v84的帖子

创建了可绑定的WindowsFormsHost,但子更新未反映到控件中

我创建遇到了一个问题,我想将控件绑定到一个windowsFormsHost控件.但是众所周知,Child属性不是DP,所以我创建了一个包装器.

/// <summary>
    ///     Bindable version of windows form hosts
    /// </summary>
    public class BindableWindowsFormsHost : WindowsFormsHost
    {
        /// <summary>
        /// Max value of the textbox
        /// </summary>
        public Control BindableChild
        {
            get { return (Control)GetValue(BindableChildProperty); }
            set 
            {
                SetValue(BindableChildProperty, value);
            }
        }

        // Using a DependencyProperty as the backing store for Max.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty BindableChildProperty =
            DependencyProperty.Register("BindableChild", typeof(Control), typeof(BindableWindowsFormsHost),  new FrameworkPropertyMetadata(new PropertyChangedCallback(OnBindableChildChanged)));

        /// <summary>
        /// Handles changes to the …
Run Code Online (Sandbox Code Playgroud)

.net wpf binding windowsformshost

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

DataContractSerializer序列化List <T>获取错误

我目前正在尝试序列化List,它序列化(我认为很好),但是当它反序列化时,

很抱歉代码的数量,但我真的卡住了,不知道为什么会发生这种情况,我也试图将结构改成一个类而没有帮助.

谢谢.

我得到以下错误更新

    There was an error deserializing the object of type There was an error deserializing the object of type 
`System.Collections.Generic.List`1[[A.B.C.DataValues, A.V, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]. Unexpected end of file. Following elements are not closed: Time, DataValues, ArrayOfDataValues.`
Run Code Online (Sandbox Code Playgroud)

我像这样更新了序列化

     public void SerializeDataValue(List<DataValues> values)
            {
                DataContractSerializer serializer = new DataContractSerializer(typeof(List<DataValues>));

                using (MemoryStream stream = new MemoryStream())
                {
                    using (GZipStream compress = new GZipStream(stream, CompressionMode.Compress))
                    {
                        XmlDictionaryWriter w = XmlDictionaryWriter.CreateBinaryWriter(compress);
                        serializer.WriteObject(w, values);

                    }
                    _serializedData = stream.ToArray();
                }
            } …
Run Code Online (Sandbox Code Playgroud)

c# serialization datacontractserializer

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

wpf datagrid复制并粘贴你看到的内容

我在wpf中使用数据网格,默认情况下它有复制和粘贴.

我有一个日期时间列,我使用绑定和字符串格式,使它以我想要的日期时间格式显示它.

但是,当我复制并粘贴时,粘贴的文本将成为未格式化的日期时间.

有没有办法复制粘贴"你看到的是什么?"

谢谢,凯夫

编辑:我尝试使用ClipboardContentBinding,与我在绑定中做的相同.那没用

wpf datagrid copy-paste wpf-controls

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

使用Process Exit代码在[Run]中显示特定文件的错误消息

使用innosetup并希望显示错误/ msgbox,如果其中一个[RUN]进程没有返回进程代码0.我正在使用它进行授权过程,如果授权不成功,我想通知用户.

我有以下内容:

Filename: "{pf32}\Common Files\Authorization.exe"; Parameters: " "{code:GetAuthorizationFilePath}" /s"; WorkingDir: "{tmp}"; Flags: skipifdoesntexist hidewizard; StatusMsg: "Authorizing License"; 
Run Code Online (Sandbox Code Playgroud)

归还给我:

Process exit code:0
Run Code Online (Sandbox Code Playgroud)

0当然是成功的,但如果它不是0我想通知用户.

有没有办法做到这一点?

谢谢和问候,Kev84

inno-setup

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

Wpf Datagrid Max Rows

我目前正在使用数据网格,我只想让用户在将CanUserAddRows设置为false之前输入最多20行数据.

我在自己的数据网格上创建了​​一个依赖属性(源自原始数据网格).我尝试使用事件" ItemContainerGenerator.ItemsChanged"并检查那里的行数,如果行计数=最大行数,那么make可以用户添加row = false(我得到一个例外,说我不允许在"添加行"期间更改它".

我想知道是否有一个很好的方法来实现这个....

谢谢和问候,凯文

wpf datagrid wpfdatagrid

5
推荐指数
2
解决办法
7465
查看次数

WPF:Treeview Item Root使用不同的模板然后使用子节点

我目前正在尝试将我的业务对象绑定到树视图作为根.而它的收藏属性就像孩子一样.[我希望通过BINDING实现这一点]

像这样的东西.

public object MyBusinessObject
{
   private int _number;
   private bool _isSelected;
   private ObservableCollection<AnotherObject> _other = new ObservableCollection<AnotherObject>();


   public int Number { get {return _number;} set {_number = value;}}
   public bool IsSelected{ get {return _isSelected;} set {_isSelected= value;}}
   public ObservableCollection<AnotherObject>  Children { get {return _other;}}

}
Run Code Online (Sandbox Code Playgroud)

我希望我的treeview像这样表示:

  • "CheckBox绑定到IsSelected""文本绑定到数字"
    • 绑定到我的"孩子"的孩子一览
    • 绑定到我的"孩子"的孩子一览
    • 绑定到我的"孩子"的孩子一览
  • "CheckBox绑定到IsSelected""文本绑定到数字"
    • 绑定到我的"孩子"的孩子一览
    • 绑定到我的"孩子"的孩子一览
    • 绑定到我的"孩子"的孩子一览

我不知道如何在xaml中执行此操作:

  <TreeView x:Name="_tv" ItemsSource="{Binding Path=MyBusinessObject}" >

            <TreeView.Resources>
                <HierarchicalDataTemplate> 
                    <CheckBox Content="{Binding Path=Number} IsChecked="{Binding Path=IsSelected}" />
                </HierarchicalDataTemplate>

                <HierarchicalDataTemplate ItemsSource="{Binding Path=Children}">
                    <TextBlock Text="{Binding Path=Name}" />
                </HierarchicalDataTemplate>
            </TreeView.Resources>
        </TreeView> …
Run Code Online (Sandbox Code Playgroud)

wpf treeview binding templates

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

.NET REGEX匹配匹配空字符串

我有这个

图案:

[0-9]*\.?[0-9]*
Run Code Online (Sandbox Code Playgroud)

目标:

X=113.3413475 Y=18.2054775
Run Code Online (Sandbox Code Playgroud)

我想匹配数字.它匹配http://regexpal.com/和Regex Coach 等测试软件中的find .

但是在Dot net和http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx

我明白了:

Found 11 matches:

1.
2.
3.
4.
5.
6.  113.3413475
7.
8.
9.
10. 18.2054775
11.

String literals for use in programs:

C#
    @"[0-9]*[\.]?[0-9]*"
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么我得到所有这些空的比赛.

谢谢和问候,凯文

.net c# regex .net-4.0 match

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

Android:在类中将Views存储为全局变量是一种好习惯吗?

我是Android的新手,并且一直在阅读内存管理在那些内存有限的应用程序中非常重要.

我读过一些活动findViewById()非常昂贵的地方.所以我想知道,如果将视图存储为全局变量并重用该对象是一个好习惯吗?或者findViewById()每次我需要使用视图时运行更好吗?

谢谢,凯夫

performance android

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

如何从转换器中引用xaml模板?

我目前停留在通过转换器为控件分配不同模板的问题上.

所以我有2个模板.

        <ControlTemplate x:Name="_templateA" x:Key="templateA">
            <StackPanel Grid.Column="0" Margin="0,0,5,0">
                <Blah />
            </StackPanel>
        </ControlTemplate>

        <ControlTemplate x:Name="_templateB" x:Key="templateB">
            <StackPanel Grid.Column="0" Margin="0,0,5,0">
                <Blah Blah />
            </StackPanel>
        </ControlTemplate>
Run Code Online (Sandbox Code Playgroud)

我使用这个转换器控制这个:

<ControlA x:Name="_controlA" >
     <Control Template="{Binding Converter={StaticResource templateConverters}}" />
</ControlA>
Run Code Online (Sandbox Code Playgroud)

我的转换器:

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        Object a;
        ControlTemplate template = null;

        try
        {
            a= value as ObjectA;
            if (value != null)
                template = a.useTemplate1 ? [templateA from xaml] : [templateB from xaml];
        }
        catch (Exception ex)
        {
            Debug.Assert(false, ex.ToString());
        } …
Run Code Online (Sandbox Code Playgroud)

wpf binding converter datatemplate controltemplate

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