Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
L

Leung Yat Chun

@Leung Yat Chun
About
Posts
11
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • WPF UserControl design question
    L Leung Yat Chun

    This may work, but not too maintainable.

    <UserControl.Triggers>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
    <BeginStoryboard>
    <Storyboard>
    <ObjectAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetProperty="Background">
    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Red" />
    </ObjectAnimationUsingKeyFrames>
    </Storyboard>
    </BeginStoryboard>
    </EventTrigger>
    </UserControl.Triggers>

    If you going to make DependencyProperty, you can inherit from current properties

    public static readonly DependencyProperty OrientationProperty =
    VirtualWrapPanel.OrientationProperty.AddOwner(typeof(VirtualWrapPanelView));

    Then Bind them in Xaml. Regards Joseph Leung

    QuickZip

    WPF wpf question csharp design help

  • WPF UserControl design question
    L Leung Yat Chun

    The proper syntax :

    public class MainControl : UserControl {
    public SubControl Sub1 {get; set;}
    }

    <bbb:MainControl x:Name="abc">
    <bbb.MainControl.Sub1>
    <SubControl x:Name="Sub1" Property1="5" Property2="Hello" />
    </bbb.MainControl.Sub1>
    </bbb:MainControl>

    If you want to change it in run time you have to use Trigger. For more information, please read WPF: A Beginner's Guide - Part 1 of n[^] Regards Joseph Leung

    QuickZip

    WPF wpf question csharp design help

  • WPF ListView scrollable height
    L Leung Yat Chun

    There may be better method, but I think this should work : You can create a ListViewItem template, so when it's last item (specify in your underlying model, or use TemplateSelector), occupy more space but not focusable. Something like the following :

    <DataTemplate x:Key="NormalColumn1Template" >
    <TextBlock Text="{Binding Text}" />
    </DataTemplate>

    <DataTemplate x:Key="LastColumn1Template" >
    <StackPanel Orientation="Vertical">
    <TextBlock Text="{Binding Text}" />
    <TextBlock Text="FreeSpace" Height="100" IsHitTestVisible="False" IsFocusable="False" Background="White" />
    </StackPanel>
    </DataTemplate>

    Regards Joseph Leung

    QuickZip

    WPF csharp wpf hardware tutorial question

  • Dynamic Image binding
    L Leung Yat Chun

    Greetings Sorry I assumed your code has error in it :) as Abhinav S said, there are no leaks, if you checked Bitmap.GetHbitmap() in MSDN you can find more information about the leak. Thanks for posting your code, I just learnt that I can set SourceStream in BitmapImage directly, but I believe my code use less memory and faster however (Bitmap vs Bitmap + MemoryStream). Regards Joseph Leung

    QuickZip

    WPF help wpf question wcf

  • Dynamic Image binding
    L Leung Yat Chun

    Greetings, I am not sure about Icon, but I used your code and loaded a png without problem.

    BitmapImage bi = new BitmapImage();
    MemoryStream stream = new MemoryStream();
    Bitmap bmp = new Bitmap(@"C:\Temp\Test.png");
    bi.BeginInit();
    bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
    stream.Seek(0, SeekOrigin.Begin);
    bi.StreamSource = stream;
    bi.EndInit();
    AppIcon = bi;

    Check if it's the problem for loading Icon (try load a bmp or png). I suggest the loading code should be placed in MyObject, your BitmapImage may be created by different thread as MyObject. Regards Joseph Leung

    QuickZip

    WPF help wpf question wcf

  • Dynamic Image binding
    L Leung Yat Chun

    Source does not accept Icon and Bitmap object, you have to convert it into BitmapImage. The code below is a converter to convert Bitmap to BitmapImage, the code below can convert Bitmap to propert BitmapImage.

    [System.Runtime.InteropServices.DllImport("gdi32.dll")]
    public static extern bool DeleteObject(IntPtr hObject);
    public static BitmapSource loadBitmap(Bitmap source)
    {
    try
    {
    IntPtr hBitmap = source.GetHbitmap();
    //Memory Leak fixes, for more info : http://social.msdn.microsoft.com/forums/en-US/wpf/thread/edcf2482-b931-4939-9415-15b3515ddac6/
    try
    {
    return Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty,
    BitmapSizeOptions.FromEmptyOptions());
    }
    finally
    {
    DeleteObject(hBitmap);
    }
    }
    catch
    {
    return new BitmapImage();
    }

        }
    

    Regards Joseph Leung

    QuickZip

    WPF help wpf question wcf

  • WPF Toolkit Datagrid Performance issue in rendering
    L Leung Yat Chun

    I have no idea about the datagrid, but did you Virtualized your ListView? e.g.

    <ListView
    VirtualizingStackPanel.IsVirtualizing="True"
    VirtualizingStackPanel.VirtualizationMode="Recycling"
    ...
    />QuickZip

    WPF csharp css wpf performance help

  • TreeView Data binding
    L Leung Yat Chun

    So you want a simple way, try this one : http://karlshifflett.wordpress.com/2007/11/10/over-reaction-to-a-simple-wpf-explorer-tree/[^] I am sure it will end up even more complex though. :laugh:

    QuickZip

    WPF wpf csharp wcf tutorial question

  • Preload ImageSource from URI
    L Leung Yat Chun

    Have you tried WritableBitmap? you can return a empty WritableBitmap, start a thread to load your URI, then when the loading is finished, update it back through Dispatcher : writeBitmap.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { //UI Thread Int32Rect outRect = new Int32Rect(0, (int)(writeBitmap.Height - height) / 2, width, height); writeBitmap.WritePixels(outRect, bits, stride, 0); })); Thats what I did for my FileToIconConverter.

    QuickZip

    WPF wpf question csharp sysadmin

  • How to attach WPF controls when maximaize the window ?
    L Leung Yat Chun

    Is this what you wanted?

    WPF wpf csharp tutorial question

  • HypreLink in WPF User control.
    L Leung Yat Chun

    I hope you found this useful : private void Windows_Loaded(object sender, RoutedEventArgs e) { AddHandler(Hyperlink.ClickEvent, (RoutedEventHandler)Hyperlink_Click); } private void Hyperlink_Click(object sender, RoutedEventArgs e) { if (e.OriginalSource is Hyperlink) { Process.Start((e.OriginalSource as Hyperlink).NavigateUri.AbsoluteUri); e.Handled = true; } }

    WPF csharp wpf question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups