|
I'm trying to simulate a translucent tube with an object travelling through it. For simplicity, the tube is a rectangle and the object is a circle behind it.
I want the tube to be transparent in the middle and opaque on the edges so only the middle of the 'inside' object is clearly visible. I've got the tube's brush's OpacityMask set to a linear gradient - but it has no affect (can't see inside). I can lower the rectangle's Opacity property but that's not giving me the tube affect I'm looking for.
I'm using .NET 4.
Thanks,
Dan
<UserControl x:Class="SilverlightTest2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
<LinearGradientBrush x:Key="TubeBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="White" Offset="0.459"/>
<GradientStop Color="White" Offset="0.604"/>
</LinearGradientBrush>
</UserControl.Resources>
<Canvas x:Name="LayoutRoot" Background="White">
<Ellipse Fill="Green" Height="40" Canvas.Left="336" Stroke="Black" Canvas.Top="41" Width="40" OpacityMask="{StaticResource TubeBrush}"/>
<Rectangle Fill="Blue" Height="39" Stroke="Black" Canvas.Top="41" Width="360" OpacityMask="{StaticResource TubeBrush}"/>
</Canvas>
</UserControl>
|
|
|
|
|
An easier solution would be to use the LinearGradientBrush for the FILL and use #aarrggbb syntax for the color stops. I.e. #ff00ff00 for opaque green and #0000ff00 for transparent green. 50% transparent green would obviously be #7f00ff00.
|
|
|
|
|
Thanks! I'm still curious as to why the OpacityMask did nothing but I can dig into that later.
Dan
|
|
|
|
|
I have no idea of both. But i want to learn.
So which one i can go for?
|
|
|
|
|
WPF is desktop
Silverlight is Web
This should be enough to base you decision on. Although the lines are quite blurred. Basically they are the same with the same learning curve - steep.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
So to start sliver light what are things i need to install?
and also give some good links or books to learn silver light?
|
|
|
|
|
For learning purposes, you could start with WPF.
Silverlight is more or less a subset of WPF.
Depends on what you want to do though.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
Ok. thanks for the reply.
Can u suggest me some good links or books to learn?
|
|
|
|
|
Unfortunately, I'm not sure about WPF books.
For Silverlight, •Pro Silverlight 4" by Matthew MacDonald, is IMO, a good book.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
Why not just search the Visual Tree for it? That would be a fairly simple, and convenient, way to do it. Just start at the root visual and iterate over the tree until you find it.
|
|
|
|
|
If you take a look at the VisualTreeHelper[^] class, you can use it to iterate over the visual tree from your root element (e.g. the top level window).
|
|
|
|
|
|
Could you please explain what the string variable "name" represents? Also please tell us in what class is the GetContentControl method defined?
|
|
|
|
|
My silverlight application seems to be using more memory and more memory every time I refresh the page.
If I close and re-open the page, the the memory usage is low but then if the page is refreshed each time, then the memory usage increases.
On each refresh of the page, the page retrieve data from the database and displays on a grid control on page.
I check the memory usage in the task manager...
How can I solve this please?
Thanks
|
|
|
|
|
For a start, don't rely on Task Manager as a gauge. It's a poor mechanism because it does not reflect real memory usage.
Get yourself a profiler and use that to monitor your application. Also, ensure that you don't maintain any hard references that aren't getting garbage collected. Unreleased event handlers are a typical bugbear here.
|
|
|
|
|
We had found in WPF before a memory leak in 3.5 if you used an indeterminate progress bar. They fixed it in WPF 4.0, but what version of Silverlight are you using? It could be a particular control.
Steve Maier
|
|
|
|
|
|
It still could be one of the controls causing it. i have not tested SL4 to see if anything there leaks.
Steve Maier
|
|
|
|
|
New to Silverlight - Using four areas Three of which looking for guidance to make a combo box work in a Silverlight Grid from a stored procedure:
Any thoughts are much appreciated
Hello,
I am new to silverlight. Can some please guide me with the appropriate syntax for displaying a combo lookup box which is being loaded by a stored procedure? In addition, can you tell me how to turn on and off the Display of the combo box. It requires two clicks to open the combo box. Here is my code:
XAML
<sdk:datagridtemplatecolumn x:name="patIdEssentrisColumn" header="Pat Id Essentris" width="SizeToHeader">
<sdk:datagridtemplatecolumn.celltemplate>
<datatemplate>
<textblock margin="2" text="{Binding PatIdEssentris}">
<sdk:datagridtemplatecolumn.celleditingtemplate>
<datatemplate>
<combobox name="cboTest"
=""
itemssource="{Binding GetComboboxItems_PatIdEssentris}"
displaymemberpath="PatientName">
Combo Box Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace CorporateHR.Web
{
public class ComboBoxItem
{
[Key]
public int ComboID_Int { get; set; }
public string ComboDisplayValue { get; set; }
private static List<comboboxitem> GetComboBoxItems(string strStoredProcedure)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RefConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand(strStoredProcedure, con);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
List<comboboxitem> comboList = new List<comboboxitem>();
con.Open();
SqlDataReader dr = cmd.ExecuteReader(behavior: CommandBehavior.CloseConnection);
while (dr.Read())
{
ComboBoxItem ComboBoxItem = new ComboBoxItem();
ComboBoxItem.ComboID_Int = Convert.ToInt32(dr[0].ToString());
ComboBoxItem.ComboDisplayValue = dr[1].ToString();
comboList.Add(ComboBoxItem);
}
return comboList;
}
public static List<comboboxitem> GetComboboxItems_PatIdEssentris()
{
return GetComboBoxItems("uspLookupPatIdEssentris");
}
//Secondary ComboBox Lookup:
public static List<comboboxitem> GetComboboxItems_Department()
{
return GetComboBoxItems("uspLookupPatIdEssentris");
}
}
}
Code Behind Page
namespace CorporateHR
{
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using CorporateHR.LoginUI;
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
this.loginContainer.Child = new LoginStatus();
this.Loaded += new RoutedEventHandler(Page_Loaded);
}
void Page_Loaded(object sender, RoutedEventArgs e)
{this.employeeDataGrid.ItemsSource = GetComboboxItems_PatIdEssentris();}
private object GetComboboxItems_PatIdEssentris()
{
throw new System.NotImplementedException();
}
|
|
|
|
|
What do you mean when you say ?
can you tell me how to turn on and off the Display of the combo box
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
My combo box works outside the grid, but it does not work inside the grid.
Question: how do I make a combo box work inside of a grid.
The following code works fine outside of the grid, but does not work in the grid. How do I make this work inside the grid?
<u><b>This works outside of the Grid:</b></u>
<ComboBox Height="23" HorizontalAlignment="Left" ItemsSource="{Binding ElementName=comboBoxItemDomainDataSource, Path=Data}" Margin="112,72,0,0" Name="comboBoxItemComboBox" VerticalAlignment="Top" Width="185" SelectionChanged="comboBoxItemComboBox_SelectionChanged" DisplayMemberPath="ComboDisplayValue">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</Grid>
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:ComboBoxItem, CreateList=true}" Height="0" LoadedData="comboBoxItemDomainDataSource_LoadedData" Name="comboBoxItemDomainDataSource" QueryName="GetComboboxItems_PatIdEssentrisQuery" Width="0">
<riaControls:DomainDataSource.DomainContext>
<my:ComboBoxItemContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<u><b>This does not work within the Grid:</b></u>
<sdk:DataGridTemplateColumn x:Name="patIdEssentrisColumn" Header="Pat Id Essentris" Width="SizeToHeader">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="2" Text="{Binding PatIdEssentris}" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
<sdk:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox Name="cboPatIdEssentris"
ItemsSource="{Binding Source={StaticResource comboBoxItemDomainDataSource}, Path=Data}"
DisplayMemberPath="PatientName"
/>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellEditingTemplate>
</sdk:DataGridTemplateColumn>
-- Modified Friday, February 11, 2011 4:32 PM
|
|
|
|
|
You may want to edit your post. Basically, you've added code that appears as HTML type tags; in other words, they are between <>tags. What you need to do is convert your tags to be <> tags so that they will display properly.
|
|
|
|
|
Hopefully this will show up now...
This works outside the grid:
<ComboBox Height="23" HorizontalAlignment="Left" ItemsSource="{Binding ElementName=comboBoxItemDomainDataSource, Path=Data}" Margin="112,72,0,0" Name="comboBoxItemComboBox" VerticalAlignment="Top" Width="185" SelectionChanged="comboBoxItemComboBox_SelectionChanged" DisplayMemberPath="ComboDisplayValue">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel >
<ItemsPanelTemplate>
<ComboBox.ItemsPanel>
<ComboBox>
<Grid>
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:ComboBoxItem, CreateList=true}" Height="0" LoadedData="comboBoxItemDomainDataSource_LoadedData" Name="comboBoxItemDomainDataSource" QueryName="GetComboboxItems_PatIdEssentrisQuery" Width="0">
<riaControls:DomainDataSource.DomainContext>
<my:ComboBoxItemContext >
<riaControls:DomainDataSource.DomainContext>
<riaControls:DomainDataSource>
This does not work inside the grid:
< sdk:DataGridTemplateColumn x:Name="patIdEssentrisColumn" Header="Pat Id Essentris" Width="SizeToHeader">
< sdk:DataGridTemplateColumn.CellTemplate>
< DataTemplate>
< TextBlock Margin="2" Text="{Binding PatIdEssentris}" >
< DataTemplate>
< sdk:DataGridTemplateColumn.CellTemplate>
< sdk:DataGridTemplateColumn.CellEditingTemplate>
< DataTemplate>
< ComboBox Name="cboPatIdEssentris"
ItemsSource="{Binding Source={StaticResource comboBoxItemDomainDataSource}, Path=Data}"
DisplayMemberPath="PatientName"
>
< DataTemplate>
< sdk:DataGridTemplateColumn.CellEditingTemplate>
< sdk:DataGridTemplateColumn>
|
|
|
|
|
Hi,
How is it possible to fill the eclipse control with Green or red?
The following does not work and I can not find an example for this issue.
eclcontrol.Fill = "Green";
Thanks
|
|
|
|
|
The reason you are having a problem is because you have to use a brush to paint the colour in. So, you need to set your code to:
SolidColorBrush brush = new SolidColorBrush();
brush.Color = Colors.Green;
ellipse.Fill = brush;
|
|
|
|