RE: Image looses clarity in wpf control template

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Linda Liu[MSFT]

    RE: Image looses clarity in wpf control template

    Hi Moondaddy,

    I downloaded your sample project and run it on my machine. I did see the
    problem on my side. The image drawn in the Button is not as clear as that
    one drawn in the Image control.

    After doing some research, I found that this is a WPF layout problem.

    When we place a control into a parent control, if the child control's Width
    and Height properties are not set, the child control will be streched to
    fill the available space within the parent control; otherwise, it will be
    centered within the parent control.

    To make the child control drawn clearly, we need to position the child
    control precisely. To do this, we can use the HorizontalAlign ment and
    Vertical Alignment properties and Margin property if necessary. Modify the
    "ccBtnLeftL ine" ControlTemplate in your sample project as follows should
    solve the problem:

    <ControlTemplat e x:Key="ccBtnLef tLine" TargetType="{x: Type ContentControl} ">
    <Border HorizontalAlign ment="Left" VerticalAlignme nt="Top"
    BorderBrush="Bl ack" BorderThickness ="0.5" Width="17" Height="17"
    x:Name="border" >
    <Image HorizontalAlign ment="Left" VerticalAlignme nt="Top"
    Margin="0.5" Width="15" Height="15" Stretch="None"
    Source="images\ btnLineLeft.gif "/>
    </Border>
    <ControlTemplat e.Triggers>
    <Trigger Property="IsMou seOver" Value="True">
    <Setter Property="Borde rBrush" TargetName="bor der"
    Value="#FF005D7 8"/>
    <Setter Property="Curso r" Value="Cross"/>
    </Trigger>

    </ControlTemplate .Triggers>
    </ControlTemplate >

    For more information on WPF Layout System, please refer to the following
    MSDN document:
    Understand how and when layout calculations occur in the Windows Presentation Foundation layout system.


    Hope this helps.
    If you have any question, please feel free to let me know.

    Sincerely,
    Linda Liu
    Microsoft Online Community Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msdnmg@microsof t.com.

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    Gain technical skills through documentation and training, earn certifications and connect with the community

    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscripti...t/default.aspx.
    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights.


  • moondaddy

    #2
    Re: Image looses clarity in wpf control template

    Thanks Linda, this is good info and I always appreciate your detailed
    responses!

    "Linda Liu[MSFT]" <v-lliu@online.mic rosoft.comwrote in message
    news:elrNEzOsIH A.1788@TK2MSFTN GHUB02.phx.gbl. ..
    Hi Moondaddy,
    >
    I downloaded your sample project and run it on my machine. I did see the
    problem on my side. The image drawn in the Button is not as clear as that
    one drawn in the Image control.
    >
    After doing some research, I found that this is a WPF layout problem.
    >
    When we place a control into a parent control, if the child control's
    Width
    and Height properties are not set, the child control will be streched to
    fill the available space within the parent control; otherwise, it will be
    centered within the parent control.
    >
    To make the child control drawn clearly, we need to position the child
    control precisely. To do this, we can use the HorizontalAlign ment and
    Vertical Alignment properties and Margin property if necessary. Modify the
    "ccBtnLeftL ine" ControlTemplate in your sample project as follows should
    solve the problem:
    >
    <ControlTemplat e x:Key="ccBtnLef tLine" TargetType="{x: Type
    ContentControl} ">
    <Border HorizontalAlign ment="Left" VerticalAlignme nt="Top"
    BorderBrush="Bl ack" BorderThickness ="0.5" Width="17" Height="17"
    x:Name="border" >
    <Image HorizontalAlign ment="Left" VerticalAlignme nt="Top"
    Margin="0.5" Width="15" Height="15" Stretch="None"
    Source="images\ btnLineLeft.gif "/>
    </Border>
    <ControlTemplat e.Triggers>
    <Trigger Property="IsMou seOver" Value="True">
    <Setter Property="Borde rBrush" TargetName="bor der"
    Value="#FF005D7 8"/>
    <Setter Property="Curso r" Value="Cross"/>
    </Trigger>
    >
    </ControlTemplate .Triggers>
    </ControlTemplate >
    >
    For more information on WPF Layout System, please refer to the following
    MSDN document:
    Understand how and when layout calculations occur in the Windows Presentation Foundation layout system.

    >
    Hope this helps.
    If you have any question, please feel free to let me know.
    >
    Sincerely,
    Linda Liu
    Microsoft Online Community Support
    >
    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msdnmg@microsof t.com.
    >
    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    Gain technical skills through documentation and training, earn certifications and connect with the community

    ications.
    >
    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscripti...t/default.aspx.
    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no
    rights.
    >
    >

    Comment

    Working...