标签: custom-controls

WPF - 资源未从Generic.xaml加载

主题\ Generic.xaml:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="WPF Commons;component/Controls/Layout/Foo/FooItem.xaml" />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)

控制\布局\富\ FooItem.xaml:

<Style TargetType="{x:Type l:FooItem}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type l:FooItem}">
                <Border>
                    <ContentPresenter ContentSource="Header" />
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)


如果我将整个样式复制到我的usercontrol资源中,它可以正常工作.但是,如果我不这样做,则usercontrol显示为空.在Expression Blend 4中,我右键单击并选择Edit Template>,但它不会让我选择Edit a Copy...哪个让我相信某些内容严重错误并且Generic.xaml未正确加载.我认为它是Generic.xaml,因为如果我删除MergedDictionary调用并将xaml样式直接复制/粘贴到Generic.xaml中,它仍然无效.

wpf custom-controls resourcedictionary generic.xaml

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

用户控件,服务器控件和自定义控件之间有什么区别?

在最近的一次采访中,我认为我对这个问题有合理的答案,但我对此进行了轰炸.:(

  • 这三者之间有哪些主要区别?
  • 如果前一个子弹的答案不明显,你什么时候选择一个?

asp.net user-controls controls custom-controls

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

如何在BlackBerry中自定义ListField?

我想在BlackBerry中自定义ListField,它能够连续列出图像和文本.

怎么做到这一点?

user-interface blackberry custom-controls listfield

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

WPF最佳实践:自定义控件是否适用于MVVM设计?

我正在寻找创建一个我可以在我的页面上重用的公共控件:一个AddressControl,它有Address1,Address2,City,State,Zip等...

最初我刚刚创建了一个AddressEntity包含所有这些项并实现的class()INotifyPropertyChanged.我在AddressControl的Code-Behind中将该类作为DependencyProperty包含在内,并将其用作DataContext以绑定其属性.

然后,有人说我的代码很难看,我应该看看MVVM.看着它,我认为:

  • AddressEntity.cs只是数据的容器(即Address1,Address2等)和成员(即Clone,ToString等)
  • 我需要一些AddressViewModel来包装我的AddressEntity并提供PropertyNotification更改,验证等.
  • 我需要以某种方式为此提供"视图".

问题是我见过的每个例子都有一个UserControl作为View而不是CustomControl.在我深入研究之前......

  • 是否可以在此示例中使用MVVM +自定义控件?
  • 除了UserControl与CustomControl的主要区别之外,它与View几乎完全相同(UserControl vs CustomControl)吗?基本上,我的CustomControl真的只是一个视图吗?

参考:WPF的Model-View-ViewModel(MVVM)设计模式

c# wpf custom-controls mvvm

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

创建WPF混合控件(TreeView + DataGrid = DataTreeGrid)

我需要创建一个保存同步数据的TreeView,比如DataGrid.

为了澄清,请看一下这张图片:
DataTreeGrid自定义控件

所以,我在左侧有一个TreeView,右侧有列.
数据将来自这样的对象:

public NodeData Parent;
public List<NodeData> Children;

public String Label;

public Boolean DataA;
public Boolean DataB;
public Boolean DataC;
public Boolean DataX;
public Boolean DataY;
public Boolean DataZ;
Run Code Online (Sandbox Code Playgroud)

我该如何创建呢?

wpf treeview datagrid custom-controls

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

如何获取使用Windows 7的图像在树视图控件中绘制父节点?

我正在使用一个混合两个窗口控件(listview和treeview)的自定义控件.在某些时候,我需要绘制使用Windows 7(启用主题)的图像来识别父节点,我正在使用DrawThemeBackground具有TVP_GLYPH部分和GLPS_CLOSED状态的函数(我尝试了与TREEVIEW该类相关的所有部分和状态而没有运气),但结果图像总是旧的(+)或( - ).

此图像显示了该问题

在此输入图像描述

我想绘制箭头图像(黑色圆圈内部)而不是(+)符号(橙色圆圈内部).

这是我用来绘制图像的示例代码.

uses
  UxTheme;

procedure TForm40.Button1Click(Sender: TObject);
var
  iPartId : integer;
  iStateId: integer;
  hTheme  : THandle;
begin
  hTheme  := OpenThemeData(Handle, VSCLASS_TREEVIEW);

  iPartId := TVP_GLYPH;
  iStateId:= GLPS_CLOSED;          
  //iPartId := TVP_TREEITEM;
  //iStateId:= TREIS_NORMAL;
  if hTheme <> 0 then
    try

      //if (IsThemeBackgroundPartiallyTransparent(hTheme, iPartId, iStateId)) then
      //    DrawThemeParentBackground(Handle, PaintBox1.Canvas.Handle, nil);

      DrawThemeBackground(hTheme, PaintBox1.Canvas.Handle, iPartId, iStateId, Rect(0, 0, 31, 31), nil);
    finally
      CloseThemeData(hTheme);
    end;
end;
Run Code Online (Sandbox Code Playgroud)

我查了一些工具,如应用程序所作的Andreas …

delphi winapi custom-controls

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

如何使WPF包装子项目伸展?

我想创建一个ItemsControl子项目放置的地方WrapPanel,但是子项目应该占用尽可能多的空间.因此,当窗口大小变大或变小时,子项应根据特定的宽度:高度比进行拉伸.当孩子项目将添加或从删除ItemsControlItemsSource,则WrapPanel应该适当地放置物品中换行,以保持子项的宽度:高度比率.
以下是我到目前为止的情况.是否可以在Xaml中执行此操作?或者我应该为此创建自定义控件?提前致谢!

<Window>
<Grid>
    <ItemsControl ItemsSource="{Binding DataCollection}">
       <ItemsControl.ItemsPanel>
          <ItemsPanelTemplate>
             <WrapPanel Orientation="Vertical"/>
          </ItemsPanelTemplate>
       </ItemsControl.ItemsPanel>
       <ItemsControl.ItemTemplate>
          <DataTemplate>
             <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Stretch">
                <StackPanel Orientation="Horizontal" >
                   <TextBlock TextWrapping="Wrap" Text="{Binding Name}" />
                   <TextBlock TextWrapping="Wrap" Text="{Binding Value}"/>
                   <TextBlock TextWrapping="Wrap" Text="{Binding Time,  StringFormat='hh:mm:ss' }"/>
                </StackPanel>
             </Border>          
         </DataTemplate>
       </ItemsControl.ItemTemplate>
    </ItemsControl>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

wpf xaml wrappanel custom-controls itemscontrol

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

WPF Adding a custom property in a control

Ok i have a WPF application in which i have a resource dictionary. In the dictionary i have a new style for a Button that looks like this :

    <Style x:Key="MenuButtonStyle" TargetType="Button">
      <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Button}">

                <Grid>
                    <Image x:Name="Imager" RenderOptions.BitmapScalingMode="HighQuality" Width="{TemplateBinding Width}"  Height="{TemplateBinding Height}" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Tag}" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="UniformToFill"/>
                </Grid>

                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="Imager" Property="Width" Value="24" />
                        <Setter TargetName="Imager" Property="Height" Value="24" />
                    </Trigger>
                    <Trigger Property="IsPressed" Value="true">
                        <Setter TargetName="Imager" Property="Width" Value="16" />
                        <Setter TargetName="Imager" Property="Height" …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml properties custom-controls

15
推荐指数
2
解决办法
3万
查看次数

如何在iOS设备上播放360视频

浏览不同的网站并分析不同的资源我发现,要在iPhone上播放360个视频,你应该使用3-d party lib(Panorama).但我真的很感兴趣,你自己可以做到这一点.因为标准iOS元素不支持此类功能.

请提供一些建议,我应该使用这些方法为360视频创建自己的播放器.

video objective-c custom-controls ios 360-degrees

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

ASP.NET中的自定义元素,带有自定义子元素

我知道可以使用用户控件在ASP.NET中定义自定义标记.但据我所知,您只能为这些控件添加属性.我希望能够嵌入更复杂的数据,有点精简:

<myControls:MyGraph id="myGraph1" runat="server">
   <colors>
     <color>#abcdef</color>
     <color>#123456</color>
   </colors>
</myControls:MyGraph>
Run Code Online (Sandbox Code Playgroud)

这在ASP.NET中可能吗?我应该尝试扩展ListView吗?还是有更好更正确的解决方案?

asp.net custom-controls

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