By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,087 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,087 IT Pros & Developers. It's quick & easy.

RE: Image looses clarity in wpf control template

P: n/a
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 HorizontalAlignment and
Vertical Alignment properties and Margin property if necessary. Modify the
"ccBtnLeftLine" ControlTemplate in your sample project as follows should
solve the problem:

<ControlTemplate x:Key="ccBtnLeftLine" TargetType="{x:Type ContentControl}">
<Border HorizontalAlignment="Left" VerticalAlignment="Top"
BorderBrush="Black" BorderThickness="0.5" Width="17" Height="17"
x:Name="border" >
<Image HorizontalAlignment="Left" VerticalAlignment="Top"
Margin="0.5" Width="15" Height="15" Stretch="None"
Source="images\btnLineLeft.gif"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" TargetName="border"
Value="#FF005D78"/>
<Setter Property="Cursor" Value="Cross"/>
</Trigger>

</ControlTemplate.Triggers>
</ControlTemplate>

For more information on WPF Layout System, please refer to the following
MSDN document:
http://msdn.microsoft.com/en-us/library/ms745058.aspx

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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
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.
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Thanks Linda, this is good info and I always appreciate your detailed
responses!

"Linda Liu[MSFT]" <v-****@online.microsoft.comwrote in message
news:el**************@TK2MSFTNGHUB02.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 HorizontalAlignment and
Vertical Alignment properties and Margin property if necessary. Modify the
"ccBtnLeftLine" ControlTemplate in your sample project as follows should
solve the problem:

<ControlTemplate x:Key="ccBtnLeftLine" TargetType="{x:Type
ContentControl}">
<Border HorizontalAlignment="Left" VerticalAlignment="Top"
BorderBrush="Black" BorderThickness="0.5" Width="17" Height="17"
x:Name="border" >
<Image HorizontalAlignment="Left" VerticalAlignment="Top"
Margin="0.5" Width="15" Height="15" Stretch="None"
Source="images\btnLineLeft.gif"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" TargetName="border"
Value="#FF005D78"/>
<Setter Property="Cursor" Value="Cross"/>
</Trigger>

</ControlTemplate.Triggers>
</ControlTemplate>

For more information on WPF Layout System, please refer to the following
MSDN document:
http://msdn.microsoft.com/en-us/library/ms745058.aspx

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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
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.


Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.