473,698 Members | 2,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:
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****@microsof t.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 2563
Thanks Linda, this is good info and I always appreciate your detailed
responses!

"Linda Liu[MSFT]" <v-****@online.mic rosoft.comwrote in message
news:el******** ******@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:
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****@microsof t.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
2047
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 error when trying to hit one of my pages... --------------------------------------------------------------------- Invalid URI: There is an invalid sequence in the string. ---------------------------------------------------------------------
0
1121
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 the code for over two days and I am still stuck. Here is the template column as it is in the datagrid now <asp:TemplateColumn HeaderText="Status"><ItemTemplate><asp:Image id=Image4 runat="server" ImageUrl='<%# gridGetImagePath...
0
1135
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 arrow to switch to the next page everything works fine except that the htmlinputfile items looses their last input.
3
2738
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 folder of flag images, named in relations to the countries database ID. Current data grid code is...
7
1756
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
3911
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 here, until I thought "It would be cool, if the user could click on that image..". So I replaced the Image-Control with an ImageButton. My Problem is, that the ImageButton doesn't fire any events. Any other
7
1775
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 the GIF appears on the form correctly i.e. the background of the form shows through the transparent part of the gif. However, if I place a BackgroundImage on the form, the transparent part of
1
2181
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 WebPartZones. Each master page implements an interface (call it IMasterPage), which provides public properties for the WebPartManager and 3 WebPartZones. (Rule #1 was static number of zones.) However, each template can have these zones be...
1
1367
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 database called status_code. I want to display an OK image when it is 0 and an alarm image when it is 1. I tried to do this by creating two cells in the gride view. One of them is
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7729
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.