How do I tell Telerik for WinForms which of its themes to use?
I created a new WinForms project and dropped a RadPageView on the form, but there's a 5-pixel margin of dead space all the way around, the tabs are almost twice as tall as they need to be, and everything is shiny and blue. Even apart from the wasted space, all this blue stuff would look horribly out of place in our app. I just want a standard Windows look, and I'm assuming that the way to accomplish that is to select a different, less-blue, less-shiny theme. (Or is there another way?)
Here's what I've tried:
I tried setting EnableTheming to False, but then the tabs have no borders at all, so there's absolutely no indication of where to click or which tab is active -- no good at all.
I can drop down the ThemeName property in the Property Grid, but the only options are "Reset" and "ControlDefault". Neither setting does anything (even with EnableTheming set back to True).
There are a bunch of Theme classes in the Toolbox (AquaTheme, BreezeTheme, etc.), but adding those to my form doesn't make any difference. I thought they might appear in the ThemeName dropdown, but they don't.
I tried dropping a RadThemeManager on my form, but it only has a LoadedThemes collection, which is empty. I can add things to it, but that just adds a ThemeSource, and setting one of those up seems to involve browsing to a file, and I don't have any theme files to browse to.
There's a ThemeClassName property on the RadPageView, but it's just a string (defaults to Telerik.WinControls.UI.RadPageView) and I have no idea what I might change it to, or how it even relates to themes.
This is ridiculous. All I want is a tab control that looks like a tab control! How can I do that?
The best way to accomplish this application-wide would be to use the ThemeResolutionService. You'll need to drag out one of the themes from the toolbox first. For example, if you add the Windows7Theme component to your form, you'd apply the theme using the following.
private void Form1_Load(object sender, EventArgs e)
{
ThemeResolutionService.ApplicationThemeName = "Windows7";
}
I recommend checking out this video related to themes as well:
http://tv.telerik.com/watch/winforms/visualstylebuilder/changing-themes-at-run-time-with-radcontrols-winforms
I'm currently working on a Winform/Telerik application.
It's a MDI application.
First, I added in the References of my Project the Telerik.Wincontrols.Themes.Breeze dll, then in the constructor of my main form, here is what I did :
private fMain()
{
InitializeComponent();
ThemeResolutionService.ApplicationThemeName = "Breeze";
RadGridLocalizationProvider.CurrentProvider = new FrenchRadGridLocalizationProvider();
}
I also added the French RadGridLocalizationProvider.
And it works, all my RadDataGridViews are in French and have the Breeze theme.
Even if the Form used is not a Telerik one, which is my case, I don't use RadForm !
To make loading of themes dynamic, I did following:
private void LoadTheme()
{
var themefiles = Directory.GetFiles(System.Windows.Forms.Application.StartupPath, "Telerik.WinControls.Themes.*.dll");
foreach (var theme in themefiles)
{
var themeAssembly = Assembly.LoadFile(theme);
var themeType = themeAssembly.GetTypes().Where(t => typeof(RadThemeComponentBase).IsAssignableFrom(t)).FirstOrDefault();
if (themeType != null)
{
RadThemeComponentBase themeObject = (RadThemeComponentBase)Activator.CreateInstance(themeType);
if (themeObject != null)
{
themeObject.Load();
}
}
}
var themeList = ThemeRepository.AvailableThemeNames.ToList();
themeDropDown.DataSource = themeList;
}
private void ThemeDropDown_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
string strTheme = themeDropDown.Text;
Theme theme = ThemeResolutionService.GetTheme(strTheme);
if (theme != null)
{
ThemeResolutionService.ApplicationThemeName = theme.Name;
}
}
I was able to achieve completely dynamic theme changing experience. In case Telerik release or updates themes in future, the only thing required will be to add the theme dlls in the application folder.
Related
I have a Wp7 that has two controls. One is a map, and the other is a panorama control. In one of the panorama items is a list of values. If a user clicks on a list item, I'd like to show a turnstile transition to a new control that shows more detail.
So far in XAML, I have an event bound to LeftMouseUp, and it triggers. However I'm now sure how to replace the current panoramaitem with a new control (view), or how to use a the TurnstileTransition provided by the silverlight toolkit, between the two.
TurnstileTransition transitionElement =
new TurnstileTransition { Mode = TurnstileTransitionMode.ForwardIn };
AlertDetailedView view = new AlertDetailedView();
view.DataContext = (e.OriginalSource as FrameworkElement).DataContext;
//this stuff below sorta doesnt really work...
ITransition transition = transitionElement.GetTransition(this);
transition.Completed += delegate
{
transition.Stop();
};
transition.Begin();
In order to fit in with WP7 Navigation (e.g. the Back Button) then I'd recommend that you use two different pages for the two controls.
For seeing how to animate page transitions, then the SL toolkit contains some helpful material - or Kevin Marshall's blog is also very helpful - e.g.
http://blogs.claritycon.com/kevinmarshall/2010/05/12/windows-phone-7-prototype-002-animated-page-transitions-writeable-bitmaps/
How can I hide one panel in Visual Studio 2008 Form Designer like a layer in PS? Otherwise, can someone recommend another better method to design multiple "screens" that must be clicked through by the user?
What you describe is a wizard, and you might want to investigate the approach from Eric J.
However, when I have cases where I want to have multiple panels in the same space within my UI and I want to switch between them in the designer, I like to use a TabControl and hide the tabs on the TabControl. This makes the UI easier to manage at design time and the code is pretty simple to switch between the tabs at run time.
I made a custom control that derives from TabControl called HiddenTabsControl that is very simple. The class only overrides the WndProc and lets the TabControl base class handle everything else. All you need to do is:
Add a New Item to your project
Choose Custom Control,
Name it something like HiddenTabsControl.
Change the base Class to TabControl, remove the Constructor and the OnPaint override that Visual Studio added.
Copy this override for WndProc into the class:
protected override void WndProc(ref Message m)
{
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328 && !DesignMode)
{
m.Result = (IntPtr)1;
}
else
{
base.WndProc(ref m);
}
}
Now you can change tabs in the designer and design the UI easily and in the code you can handle events to change tabs as needed. Changing the Selected tab is easily done with:
this.hiddenTabsControl.SelectedTab = this.tabPageYouWantVisible;
One side effect of removing the tabs is the space that the tabs occupy when the control is constructed. Removing them will make the space the HiddenTabsControl occupies change by shrinking it. I usually set the Anchor of the HiddenTabsControl to bottom to keep it from shrinking.
I used this Wizard code in a recent project and it worked well.
It provides the basic experience you are after.
Another less elegant, but quick hack, approach is to simply not add the panel to the parent form until runtime. In doing that, the designer has no idea where the panel belongs prior to compilation, and it won't be displayed.
For example, find the block of code where you add controls to the parent form:
//this->Controls->Add(this->panel_X);
this->Controls->Add(this->tabControl);
this->Controls->Add(this->menuStrip_topMenu);
Comment or remove the statement, then find the handle to the event that occurs when the form is loaded:
this->Load += gcnew System::EventHandler(this, &MainForm::MainForm_Load);
Then in the definition of the event handler, add the control to the form:
System::Void MainForm_Load(System::Object^ sender, System::EventArgs^ e) {
...
...
this->Controls->Add(this->panel_X);
}
I haven't experienced any unwanted side effects by doing this, but if anyone has a good reason to not I'd be interested in hearing it.
Im developing some wpf app. Basically i have two types of windows: search windows and insert/edit windows. When i developed win forms apps, i used a trick, called MdiParent. In that way i had ability to put my caled search type windows in a "stack". In orher words if i called 5 different search windows from meniu, they apeared in a component like tab control, one after other.By clicking on that tabs, i could see search results of clicked tab window. The trick as i said was MdiParent technique, like:
private ProductDiscount frmProductDiscount = null;
private void ProductDiscountToolStripMenuItem_Click(object sender, EventArgs e)
{
if ((frmProductDiscount == null) || (!frmProductDiscount.Visible))
{
frmProductDiscount = new ProductDiscount();
frmProductDiscount.MdiParent = this;
frmProductDiscount.Show();
}
else
{
frmProductDiscount.Activate();
}
}
So does anyone can me suggest a good way to implement such a window organization technique in WPF and put some links or examples..?That would be a big help for me.
There is no equivalent of Form.MDIParent in WPF and MDI does not support the idea of an MDI layout. You can set a Windows Owner to another window. This will minimise the child when the parent is minimised.
For an example of MDI style functionality have a look at this thread link text
where Marlon Grech has written something similar to what I believe you are trying to do.
We developped similar application, as WPF doesnt have any default MDI framework but since its completely customizable, what you can do is, you can create User Controls of your "Window" instead of Window type and you can use inside a TabControl and you can customize TabControl to have close buttons etc. Windows in Tabs as they appear in Visual Studio, IE etc, they work good for this type of scenario when you dont want to block user input on modal dialog.
I have a bunch of Forms that I embed in tabpages(some are embedded two and three layers deep) that I now suspect are giving me trouble. I have been told that User Control's are the better approach.
Now I am wondering how I
canaccomplish this as quick as
possible.
Is it as simple as copy and paste?
Has anyone ever done something like
this?
I have about 40 forms that I embedd that would need to be moved and not a lot of time to do it so any help is greatly appreciated.
EDIT 1
This is how I embed forms:
public static void ShowFormInContainerControl(Control ctl, Form frm)
{
frm.TopLevel = false;
frm.FormBorderStyle = FormBorderStyle.None;
frm.Dock = DockStyle.Fill;
frm.Visible = true;
ctl.Controls.Add(frm);
}
public static void DockControl(this Control control, UserControl userControl)
{
userControl.Dock = DockStyle.Fill;
control.Controls.Clear();
control.Controls.Add(userControl);
}
Not sure if it's the "best", but this is probably the most efficient. Change the classes to inherit from UserControl instead of Form. Then fix the compiler errors if/when you get any (see NOTE 2 below).
NOTE 1: If you're not using version control, start using it before doing something drastic like this. You'll want to be able to go back if something goes too far south.
NOTE 2: If you use any particular events or properties of Form that aren't implemented in UserControl, you'll have to think of a solution. Some properties (Icon for example) you can safely just ignore (= delete the line from the designer file).
NOTE 3: If you use the forms as an actual form somewhere, you'll want to also have a form that uses the newly created UserControl. You're most likely to get in trouble here with naming, so keep a sharp eye.
I need to display a variable-length message and allow the text to be selectable. I have made the TextBox ReadOnly which does not allow the text to be edited, but the input caret is still shown.
The blinking input caret is confusing. How do I hide it?
You can do through a win32 call
[DllImport("user32.dll")]
static extern bool HideCaret(IntPtr hWnd);
public void HideCaret()
{
HideCaret(someTextBox.Handle);
}
When using the win32 call don't forget to hide the cursor in the textbox's GotFocus event.
Just for completeness, I needed such a functionality for using with a DevExpress WinForms TextEdit control.
They already do provide a ShowCaret and a HideCaret method, unfortunately they are protected. Therefore I created a derived class that provides the functionality. Here is the full code:
public class MyTextEdit : TextEdit
{
private bool _wantHideCaret;
public void DoHideCaret()
{
HideCaret();
_wantHideCaret = true;
}
public void DoShowCaret()
{
ShowCaret();
_wantHideCaret = false;
}
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
if (_wantHideCaret)
{
HideCaret();
}
}
}
To use the code, simply use the derived class instead of the original TextEdit class in your code and call DoHideCaret() anywhere, e.g. in the constructor of your form that contains the text edit control.
Maybe this is helpful to someone in the future.
If you disable the text box (set Enable=false), the text in it is still scrollable and selectable. If you don't like the visual presentation of a disabled text box (gray background usually) you can manually override the colors.
Be warned, manually overriding colors is going to make your form/control look weird on systems that do not use the default color/theme settings. Don't assume that because your control is white that everyone's control is going to be white. That's why you should always use the system colors whenever possible (defined in the System.Drawing.SystemColors enumeration) such as SystemColors.ControlLight.
I know this is an old thread but it is a useful reference.
I solved the problem with a much easier but very kludgie solution, which may depend on how much control you have over the user's access to the form. I added a textbox (any focus-able control) which I gave prime tabIndex value and then positioned it off-form so that it was not visible. This works fine on a dialog because the user can't resize. If the form is resizeable, this may not work.
As I said, a kludge - but a lot easier to set up. (BTW I found the HideCaret approach didn't work - but I didn't pursue it hard.)
AFAIK, this cannot be done. The TextBox control is a funny control because it actually has a lot of behaviour that can't be modified due to the way it taps into the operating system. This is why many of the cool custom TextBoxes are written from scratch.
I am afraid you may not be able to do what you wish to do :(