473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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 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
1 2554
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Greg Christie | last post by:
I think I have a somewhat unique situation here, so I thought I should post it for the few poor souls who run across it and try to google it like I did. First of all, I was getting the following...
0
by: Michelle Stone | last post by:
i am puzzled. i have previously bound datasets to datagrids which contain the filename of IMAGES. And i use template columns to show the image for each row. But now it is not working. I have reviewed...
0
by: mizd | last post by:
Hi, does anybody have a hint how to solve this. I have a datagrid with a template column (all in code behind technique). the datagrid has paging with ten items. when I select the paging...
3
by: Simon Harris | last post by:
Hi All, I have a data grid which displays country names. I now wish to display the country flag images above the names. Can someone please advise how I display an image in a datagrid? I have a...
7
by: Miguel Dias Moura | last post by:
Hello, In an ASP.Net / VB web page I want to display an image which filename depends of a parameter on the URL. I have this:
3
by: jens.buchta | last post by:
Hi! I'm using a DataGrid with a template column to display an Image inside of it. I'm hooking into its OnPrerender-Event to set the ImageURL-Property dynamically. Everything works just fine...
7
by: G .Net | last post by:
Hi I have a form on which I have a picture box. I have placed a GIF as the image for this picture box. The GIF has a transparent background. If I change the background color of the form, then...
1
by: rudjohn | last post by:
I've been tasked with the not-enviable job of creating an application with multiple, semi-customizable templates. My basic concept, thus far, has been a combination of Master Pages (for layout) and...
1
by: ma | last post by:
Hello, I have a grideview which is bound to a database. I want that based on the value of one field on the database one image is shown in the gideview. For example assume that I have a field in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.